mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Renamed GxsMails to GxsTrans
GxsTrans is a generic transport service, use more generic name trans instead of mail to avoid confusion Renamed size(...) to seria_size(...) for costistence whit the codebase Moved GxsTrans and related things to gxstrans directory Removed outdated and now uncompatible gxsmail test service Avoid expose internal items in public interface methods
This commit is contained in:
parent
08161db43b
commit
da459c884e
@ -40,6 +40,7 @@
|
|||||||
#include "pqi/p3historymgr.h"
|
#include "pqi/p3historymgr.h"
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "services/p3idservice.h"
|
#include "services/p3idservice.h"
|
||||||
|
#include "gxstrans/p3gxstrans.h"
|
||||||
|
|
||||||
#include "chat/p3chatservice.h"
|
#include "chat/p3chatservice.h"
|
||||||
#include "serialiser/rsconfigitems.h"
|
#include "serialiser/rsconfigitems.h"
|
||||||
@ -55,16 +56,16 @@ static const uint32_t MAX_AVATAR_JPEG_SIZE = 32767; // Maximum size
|
|||||||
|
|
||||||
p3ChatService::p3ChatService( p3ServiceControl *sc, p3IdService *pids,
|
p3ChatService::p3ChatService( p3ServiceControl *sc, p3IdService *pids,
|
||||||
p3LinkMgr *lm, p3HistoryMgr *historyMgr,
|
p3LinkMgr *lm, p3HistoryMgr *historyMgr,
|
||||||
p3GxsMails& gxsMailService ) :
|
p3GxsTrans& gxsTransService ) :
|
||||||
DistributedChatService(getServiceInfo().mServiceType, sc, historyMgr,pids),
|
DistributedChatService(getServiceInfo().mServiceType, sc, historyMgr,pids),
|
||||||
mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm),
|
mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm),
|
||||||
mHistoryMgr(historyMgr), _own_avatar(NULL),
|
mHistoryMgr(historyMgr), _own_avatar(NULL),
|
||||||
_serializer(new RsChatSerialiser()),
|
_serializer(new RsChatSerialiser()),
|
||||||
mDGMutex("p3ChatService distant id - gxs id map mutex"),
|
mDGMutex("p3ChatService distant id - gxs id map mutex"),
|
||||||
mGxsTransport(gxsMailService)
|
mGxsTransport(gxsTransService)
|
||||||
{
|
{
|
||||||
addSerialType(_serializer);
|
addSerialType(_serializer);
|
||||||
mGxsTransport.registerGxsMailsClient( GxsMailSubServices::P3_CHAT_SERVICE,
|
mGxsTransport.registerGxsTransClient( GxsTransSubServices::P3_CHAT_SERVICE,
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +336,7 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||||||
// this is not very nice, because the user may think the message was send, while it is still in the queue
|
// this is not very nice, because the user may think the message was send, while it is still in the queue
|
||||||
mHistoryMgr->addMessage(message);
|
mHistoryMgr->addMessage(message);
|
||||||
|
|
||||||
RsGxsMailId tId = RSRandom::random_u64();
|
RsGxsTransId tId = RSRandom::random_u64();
|
||||||
|
|
||||||
if(destination.isDistantChatId())
|
if(destination.isDistantChatId())
|
||||||
{
|
{
|
||||||
@ -348,7 +349,7 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||||||
uint32_t sz = ci->serial_size();
|
uint32_t sz = ci->serial_size();
|
||||||
std::vector<uint8_t> data; data.resize(sz);
|
std::vector<uint8_t> data; data.resize(sz);
|
||||||
ci->serialise(&data[0], sz);
|
ci->serialise(&data[0], sz);
|
||||||
mGxsTransport.sendMail(tId, GxsMailSubServices::P3_CHAT_SERVICE,
|
mGxsTransport.sendMail(tId, GxsTransSubServices::P3_CHAT_SERVICE,
|
||||||
de.from, de.to, &data[0], sz);
|
de.from, de.to, &data[0], sz);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -706,9 +707,10 @@ bool p3ChatService::initiateDistantChatConnexion( const RsGxsId& to_gxs_id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::receiveGxsMail( const RsGxsId& authorId,
|
bool p3ChatService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& recipientId,
|
const RsGxsId& recipientId,
|
||||||
const uint8_t* data, uint32_t dataSize )
|
const uint8_t* data,
|
||||||
|
uint32_t dataSize )
|
||||||
{
|
{
|
||||||
DistantChatPeerId pid;
|
DistantChatPeerId pid;
|
||||||
uint32_t error_code;
|
uint32_t error_code;
|
||||||
@ -724,22 +726,22 @@ bool p3ChatService::receiveGxsMail( const RsGxsId& authorId,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "p3ChatService::receiveGxsMail(...) (EE) failed initiating"
|
std::cerr << __PRETTY_FUNCTION__ << " (EE) failed initiating"
|
||||||
<< " distant chat connection error: "<< error_code
|
<< " distant chat connection error: "<< error_code
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
bool p3ChatService::notifyGxsTransSendStatus(RsGxsTransId mailId,
|
||||||
GxsMailStatus status )
|
GxsTransSendStatus status )
|
||||||
{
|
{
|
||||||
if ( status != GxsMailStatus::RECEIPT_RECEIVED ) return true;
|
if ( status != GxsTransSendStatus::RECEIPT_RECEIVED ) return true;
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mChatMtx);
|
RS_STACK_MUTEX(mChatMtx);
|
||||||
auto it = privateOutgoingMap.find(originalMessage.mailId);
|
auto it = privateOutgoingMap.find(mailId);
|
||||||
if( it != privateOutgoingMap.end() )
|
if( it != privateOutgoingMap.end() )
|
||||||
{
|
{
|
||||||
privateOutgoingMap.erase(it);
|
privateOutgoingMap.erase(it);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "chat/distantchat.h"
|
#include "chat/distantchat.h"
|
||||||
#include "chat/distributedchat.h"
|
#include "chat/distributedchat.h"
|
||||||
#include "retroshare/rsmsgs.h"
|
#include "retroshare/rsmsgs.h"
|
||||||
#include "services/p3gxsmails.h"
|
#include "gxstrans/p3gxstrans.h"
|
||||||
#include "util/rsdeprecate.h"
|
#include "util/rsdeprecate.h"
|
||||||
|
|
||||||
class p3ServiceControl;
|
class p3ServiceControl;
|
||||||
@ -55,10 +55,10 @@ typedef RsPeerId ChatLobbyVirtualPeerId ;
|
|||||||
*/
|
*/
|
||||||
struct p3ChatService :
|
struct p3ChatService :
|
||||||
p3Service, DistantChatService, DistributedChatService, p3Config,
|
p3Service, DistantChatService, DistributedChatService, p3Config,
|
||||||
pqiServiceMonitor, GxsMailsClient
|
pqiServiceMonitor, GxsTransClient
|
||||||
{
|
{
|
||||||
p3ChatService( p3ServiceControl *cs, p3IdService *pids,p3LinkMgr *cm,
|
p3ChatService(p3ServiceControl *cs, p3IdService *pids, p3LinkMgr *cm,
|
||||||
p3HistoryMgr *historyMgr, p3GxsMails& gxsMailService );
|
p3HistoryMgr *historyMgr, p3GxsTrans& gxsTransService );
|
||||||
|
|
||||||
virtual RsServiceInfo getServiceInfo();
|
virtual RsServiceInfo getServiceInfo();
|
||||||
|
|
||||||
@ -171,14 +171,14 @@ struct p3ChatService :
|
|||||||
uint32_t& error_code,
|
uint32_t& error_code,
|
||||||
bool notify = true );
|
bool notify = true );
|
||||||
|
|
||||||
/// @see GxsMailsClient::receiveGxsMail(...)
|
/// @see GxsTransClient::receiveGxsTransMail(...)
|
||||||
virtual bool receiveGxsMail( const RsGxsId& authorId,
|
virtual bool receiveGxsTransMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& recipientId,
|
const RsGxsId& recipientId,
|
||||||
const uint8_t* data, uint32_t dataSize );
|
const uint8_t* data, uint32_t dataSize );
|
||||||
|
|
||||||
/// @see GxsMailsClient::notifySendMailStatus(...)
|
/// @see GxsTransClient::notifySendMailStatus(...)
|
||||||
virtual bool notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
virtual bool notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||||
GxsMailStatus status );
|
GxsTransSendStatus status );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -270,7 +270,7 @@ private:
|
|||||||
DIDEMap mDistantGxsMap;
|
DIDEMap mDistantGxsMap;
|
||||||
RsMutex mDGMutex;
|
RsMutex mDGMutex;
|
||||||
|
|
||||||
p3GxsMails& mGxsTransport;
|
p3GxsTrans& mGxsTransport;
|
||||||
};
|
};
|
||||||
|
|
||||||
class p3ChatService::StateStringInfo
|
class p3ChatService::StateStringInfo
|
||||||
|
@ -16,39 +16,39 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "p3gxsmails.h"
|
#include "gxstrans/p3gxstrans.h"
|
||||||
#include "util/stacktrace.h"
|
#include "util/stacktrace.h"
|
||||||
|
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
p3GxsMails::~p3GxsMails()
|
p3GxsTrans::~p3GxsTrans()
|
||||||
{
|
{
|
||||||
p3Config::saveConfiguration();
|
p3Config::saveConfiguration();
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(mIngoingMutex);
|
||||||
for ( auto& kv : ingoingQueue ) delete kv.second;
|
for ( auto& kv : mIngoingQueue ) delete kv.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::sendMail( RsGxsMailId& mailId,
|
bool p3GxsTrans::sendMail( RsGxsTransId& mailId,
|
||||||
GxsMailSubServices service,
|
GxsTransSubServices service,
|
||||||
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, uint32_t size,
|
||||||
RsGxsMailEncryptionMode cm )
|
RsGxsTransEncryptionMode cm )
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::sendEmail(...)" << std::endl;
|
std::cout << "p3GxsTrans::sendEmail(...)" << std::endl;
|
||||||
|
|
||||||
if(!idService.isOwnId(own_gxsid))
|
if(!mIdService.isOwnId(own_gxsid))
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::sendEmail(...) isOwnId(own_gxsid) false!"
|
std::cerr << "p3GxsTrans::sendEmail(...) isOwnId(own_gxsid) false!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(recipient.isNull())
|
if(recipient.isNull())
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::sendEmail(...) got invalid recipient"
|
std::cerr << "p3GxsTrans::sendEmail(...) got invalid recipient"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
return false;
|
return false;
|
||||||
@ -60,18 +60,19 @@ bool p3GxsMails::sendMail( RsGxsMailId& mailId,
|
|||||||
pr.mailItem.mailId = RSRandom::random_u64();
|
pr.mailItem.mailId = RSRandom::random_u64();
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(outgoingMutex);
|
RS_STACK_MUTEX(mOutgoingMutex);
|
||||||
outgoingQueue.insert(prMap::value_type(pr.mailItem.mailId, pr));
|
mOutgoingQueue.insert(prMap::value_type(pr.mailItem.mailId, pr));
|
||||||
}
|
}
|
||||||
|
|
||||||
mailId = pr.mailItem.mailId;
|
mailId = pr.mailItem.mailId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::querySendMailStatus(RsGxsMailId mailId, GxsMailStatus& st)
|
bool p3GxsTrans::querySendStatus(RsGxsTransId mailId, GxsTransSendStatus& st)
|
||||||
{
|
{
|
||||||
auto it = outgoingQueue.find(mailId);
|
RS_STACK_MUTEX(mOutgoingMutex);
|
||||||
if( it != outgoingQueue.end() )
|
auto it = mOutgoingQueue.find(mailId);
|
||||||
|
if( it != mOutgoingQueue.end() )
|
||||||
{
|
{
|
||||||
st = it->second.status;
|
st = it->second.status;
|
||||||
return true;
|
return true;
|
||||||
@ -79,16 +80,16 @@ bool p3GxsMails::querySendMailStatus(RsGxsMailId mailId, GxsMailStatus& st)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::registerGxsMailsClient(
|
void p3GxsTrans::registerGxsTransClient(
|
||||||
GxsMailSubServices serviceType, GxsMailsClient* service)
|
GxsTransSubServices serviceType, GxsTransClient* service)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(servClientsMutex);
|
RS_STACK_MUTEX(mServClientsMutex);
|
||||||
servClients[serviceType] = service;
|
mServClients[serviceType] = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::handleResponse(" << token << ", " << req_type
|
std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type
|
||||||
<< ")" << std::endl;
|
<< ")" << std::endl;
|
||||||
switch (req_type)
|
switch (req_type)
|
||||||
{
|
{
|
||||||
@ -116,7 +117,7 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
|
|
||||||
bool shoudlSubscribe = !subscribed && ( !old || supersede );
|
bool shoudlSubscribe = !subscribed && ( !old || supersede );
|
||||||
bool shoudlUnSubscribe = subscribed && old
|
bool shoudlUnSubscribe = subscribed && old
|
||||||
&& meta.mGroupId != preferredGroupId;
|
&& meta.mGroupId != mPreferredGroupId;
|
||||||
|
|
||||||
if(shoudlSubscribe)
|
if(shoudlSubscribe)
|
||||||
subscribeToGroup(token, meta.mGroupId, true);
|
subscribeToGroup(token, meta.mGroupId, true);
|
||||||
@ -129,7 +130,7 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
timeinfo = localtime(&meta.mLastPost);
|
timeinfo = localtime(&meta.mLastPost);
|
||||||
strftime(buff, sizeof(buff), "%Y %b %d %H:%M", timeinfo);
|
strftime(buff, sizeof(buff), "%Y %b %d %H:%M", timeinfo);
|
||||||
|
|
||||||
std::cout << "p3GxsMails::handleResponse(...) GROUPS_LIST "
|
std::cout << "p3GxsTrans::handleResponse(...) GROUPS_LIST "
|
||||||
<< "meta.mGroupId: " << meta.mGroupId
|
<< "meta.mGroupId: " << meta.mGroupId
|
||||||
<< " meta.mLastPost: " << buff
|
<< " meta.mLastPost: " << buff
|
||||||
<< " subscribed: " << subscribed
|
<< " subscribed: " << subscribed
|
||||||
@ -142,7 +143,7 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
delete grp;
|
delete grp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preferredGroupId.isNull())
|
if(mPreferredGroupId.isNull())
|
||||||
{
|
{
|
||||||
/* This is true only at first run when we haven't received mail
|
/* This is true only at first run when we haven't received mail
|
||||||
* distribuition groups from friends
|
* distribuition groups from friends
|
||||||
@ -150,10 +151,10 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
* avoid to create yet another never used mail distribution group.
|
* avoid to create yet another never used mail distribution group.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::cerr << "p3GxsMails::handleResponse(...) preferredGroupId.isNu"
|
std::cerr << "p3GxsTrans::handleResponse(...) preferredGroupId.isNu"
|
||||||
<< "ll() let's create a new group." << std::endl;
|
<< "ll() let's create a new group." << std::endl;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
publishGroup(token, new RsGxsMailGroupItem());
|
publishGroup(token, new RsGxsTransGroupItem());
|
||||||
queueRequest(token, GROUP_CREATE);
|
queueRequest(token, GROUP_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
}
|
}
|
||||||
case GROUP_CREATE:
|
case GROUP_CREATE:
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::handleResponse(...) GROUP_CREATE" << std::endl;
|
std::cerr << "p3GxsTrans::handleResponse(...) GROUP_CREATE" << std::endl;
|
||||||
RsGxsGroupId grpId;
|
RsGxsGroupId grpId;
|
||||||
acknowledgeTokenGrp(token, grpId);
|
acknowledgeTokenGrp(token, grpId);
|
||||||
supersedePreferredGroup(grpId);
|
supersedePreferredGroup(grpId);
|
||||||
@ -169,7 +170,7 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
}
|
}
|
||||||
case MAILS_UPDATE:
|
case MAILS_UPDATE:
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::handleResponse(...) MAILS_UPDATE" << std::endl;
|
std::cout << "p3GxsTrans::handleResponse(...) MAILS_UPDATE" << std::endl;
|
||||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> > GxsMsgDataMap;
|
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> > GxsMsgDataMap;
|
||||||
GxsMsgDataMap gpMsgMap;
|
GxsMsgDataMap gpMsgMap;
|
||||||
getMsgData(token, gpMsgMap);
|
getMsgData(token, gpMsgMap);
|
||||||
@ -181,27 +182,27 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
for( vT::const_iterator mIt = mv.begin(); mIt != mv.end(); ++mIt )
|
for( vT::const_iterator mIt = mv.begin(); mIt != mv.end(); ++mIt )
|
||||||
{
|
{
|
||||||
RsGxsMsgItem* gIt = *mIt;
|
RsGxsMsgItem* gIt = *mIt;
|
||||||
switch(static_cast<GxsMailItemsSubtypes>(gIt->PacketSubType()))
|
switch(static_cast<GxsTransItemsSubtypes>(gIt->PacketSubType()))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
{
|
{
|
||||||
RsGxsMailBaseItem* mb =
|
RsGxsTransBaseItem* mb =
|
||||||
dynamic_cast<RsGxsMailBaseItem*>(*mIt);
|
dynamic_cast<RsGxsTransBaseItem*>(*mIt);
|
||||||
if(mb)
|
if(mb)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(mIngoingMutex);
|
||||||
ingoingQueue.insert(inMap::value_type(mb->mailId, mb));
|
mIngoingQueue.insert(inMap::value_type(mb->mailId, mb));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cerr << "p3GxsMails::handleResponse(...) "
|
std::cerr << "p3GxsTrans::handleResponse(...) "
|
||||||
<< "GXS_MAIL_SUBTYPE_MAIL cast error, "
|
<< "GXS_MAIL_SUBTYPE_MAIL cast error, "
|
||||||
<< "something really wrong is happening"
|
<< "something really wrong is happening"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
std::cerr << "p3GxsMails::handleResponse(...) MAILS_UPDATE "
|
std::cerr << "p3GxsTrans::handleResponse(...) MAILS_UPDATE "
|
||||||
<< "Unknown mail subtype : "
|
<< "Unknown mail subtype : "
|
||||||
<< static_cast<uint>(gIt->PacketSubType())
|
<< static_cast<uint>(gIt->PacketSubType())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -213,51 +214,51 @@ void p3GxsMails::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
std::cerr << "p3GxsMails::handleResponse(...) Unknown req_type: "
|
std::cerr << "p3GxsTrans::handleResponse(...) Unknown req_type: "
|
||||||
<< req_type << std::endl;
|
<< req_type << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::service_tick()
|
void p3GxsTrans::service_tick()
|
||||||
{
|
{
|
||||||
GxsTokenQueue::checkRequests();
|
GxsTokenQueue::checkRequests();
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(outgoingMutex);
|
RS_STACK_MUTEX(mOutgoingMutex);
|
||||||
for ( auto it = outgoingQueue.begin(); it != outgoingQueue.end(); )
|
for ( auto it = mOutgoingQueue.begin(); it != mOutgoingQueue.end(); )
|
||||||
{
|
{
|
||||||
OutgoingRecord& pr(it->second);
|
OutgoingRecord& pr(it->second);
|
||||||
GxsMailStatus oldStatus = pr.status;
|
GxsTransSendStatus oldStatus = pr.status;
|
||||||
processOutgoingRecord(pr);
|
processOutgoingRecord(pr);
|
||||||
if (oldStatus != pr.status) notifyClientService(pr);
|
if (oldStatus != pr.status) notifyClientService(pr);
|
||||||
if( pr.status >= GxsMailStatus::RECEIPT_RECEIVED )
|
if( pr.status >= GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||||
it = outgoingQueue.erase(it);
|
it = mOutgoingQueue.erase(it);
|
||||||
else ++it;
|
else ++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(mIngoingMutex);
|
||||||
for( auto it = ingoingQueue.begin(); it != ingoingQueue.end(); )
|
for( auto it = mIngoingQueue.begin(); it != mIngoingQueue.end(); )
|
||||||
{
|
{
|
||||||
switch(static_cast<GxsMailItemsSubtypes>(
|
switch(static_cast<GxsTransItemsSubtypes>(
|
||||||
it->second->PacketSubType()))
|
it->second->PacketSubType()))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
{
|
{
|
||||||
RsGxsMailItem* msg = dynamic_cast<RsGxsMailItem*>(it->second);
|
RsGxsTransMailItem* msg = dynamic_cast<RsGxsTransMailItem*>(it->second);
|
||||||
if(!msg)
|
if(!msg)
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::service_tick() (EE) "
|
std::cerr << "p3GxsTrans::service_tick() (EE) "
|
||||||
<< "GXS_MAIL_SUBTYPE_MAIL dynamic_cast failed, "
|
<< "GXS_MAIL_SUBTYPE_MAIL dynamic_cast failed, "
|
||||||
<< "something really wrong is happening!"
|
<< "something really wrong is happening!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::service_tick() "
|
std::cout << "p3GxsTrans::service_tick() "
|
||||||
<< "GXS_MAIL_SUBTYPE_MAIL handling: "
|
<< "GXS_MAIL_SUBTYPE_MAIL handling: "
|
||||||
<< msg->meta.mMsgId
|
<< msg->meta.mMsgId
|
||||||
<< " with cryptoType: "
|
<< " with cryptoType: "
|
||||||
@ -270,18 +271,18 @@ void p3GxsMails::service_tick()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt* rcpt =
|
RsGxsTransPresignedReceipt* rcpt =
|
||||||
dynamic_cast<RsGxsMailPresignedReceipt*>(it->second);
|
dynamic_cast<RsGxsTransPresignedReceipt*>(it->second);
|
||||||
if(!rcpt)
|
if(!rcpt)
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::service_tick() (EE) "
|
std::cerr << "p3GxsTrans::service_tick() (EE) "
|
||||||
<< "GXS_MAIL_SUBTYPE_RECEIPT dynamic_cast failed,"
|
<< "GXS_MAIL_SUBTYPE_RECEIPT dynamic_cast failed,"
|
||||||
<< " something really wrong is happening!"
|
<< " something really wrong is happening!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else if(idService.isOwnId(rcpt->meta.mAuthorId))
|
else if(mIdService.isOwnId(rcpt->meta.mAuthorId))
|
||||||
{
|
{
|
||||||
/* It is a receipt for a mail sent by this node live it in
|
/* It is a receipt for a mail sent by this node live it in
|
||||||
* ingoingQueue so processOutgoingRecord(...) will take care
|
* ingoingQueue so processOutgoingRecord(...) will take care
|
||||||
@ -298,27 +299,27 @@ void p3GxsMails::service_tick()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
std::cerr << "p3GxsMails::service_tick() (EE) got something "
|
std::cerr << "p3GxsTrans::service_tick() (EE) got something "
|
||||||
<< "really unknown into ingoingQueue!!" << std::endl;
|
<< "really unknown into ingoingQueue!!" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete it->second; it = ingoingQueue.erase(it);
|
delete it->second; it = mIngoingQueue.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGenExchange::ServiceCreate_Return p3GxsMails::service_CreateGroup(
|
RsGenExchange::ServiceCreate_Return p3GxsTrans::service_CreateGroup(
|
||||||
RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/ )
|
RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/ )
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::service_CreateGroup(...) "
|
std::cout << "p3GxsTrans::service_CreateGroup(...) "
|
||||||
<< grpItem->meta.mGroupId << std::endl;
|
<< grpItem->meta.mGroupId << std::endl;
|
||||||
return SERVICE_CREATE_SUCCESS;
|
return SERVICE_CREATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::notifyChanges(...)" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...)" << std::endl;
|
||||||
for( std::vector<RsGxsNotify*>::const_iterator it = changes.begin();
|
for( std::vector<RsGxsNotify*>::const_iterator it = changes.begin();
|
||||||
it != changes.end(); ++it )
|
it != changes.end(); ++it )
|
||||||
{
|
{
|
||||||
@ -327,12 +328,12 @@ void p3GxsMails::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
|
|
||||||
if (grpChange)
|
if (grpChange)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::notifyChanges(...) grpChange" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...) grpChange" << std::endl;
|
||||||
requestGroupsData(&(grpChange->mGrpIdList));
|
requestGroupsData(&(grpChange->mGrpIdList));
|
||||||
}
|
}
|
||||||
else if(msgChange)
|
else if(msgChange)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::notifyChanges(...) msgChange" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...) msgChange" << std::endl;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
getTokenService()->requestMsgInfo( token, 0xcaca,
|
getTokenService()->requestMsgInfo( token, 0xcaca,
|
||||||
@ -348,7 +349,7 @@ void p3GxsMails::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
for(itT vit = msgsIds.begin(); vit != msgsIds.end(); ++vit)
|
for(itT vit = msgsIds.begin(); vit != msgsIds.end(); ++vit)
|
||||||
{
|
{
|
||||||
const RsGxsMessageId& msgId = *vit;
|
const RsGxsMessageId& msgId = *vit;
|
||||||
std::cout << "p3GxsMails::notifyChanges(...) got "
|
std::cout << "p3GxsTrans::notifyChanges(...) got "
|
||||||
<< "notification for message " << msgId
|
<< "notification for message " << msgId
|
||||||
<< " in group " << grpId << std::endl;
|
<< " in group " << grpId << std::endl;
|
||||||
}
|
}
|
||||||
@ -357,7 +358,7 @@ void p3GxsMails::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t p3GxsMails::AuthenPolicy()
|
uint32_t p3GxsTrans::AuthenPolicy()
|
||||||
{
|
{
|
||||||
uint32_t policy = 0;
|
uint32_t policy = 0;
|
||||||
uint32_t flag = 0;
|
uint32_t flag = 0;
|
||||||
@ -386,9 +387,9 @@ uint32_t p3GxsMails::AuthenPolicy()
|
|||||||
return policy;
|
return policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::requestGroupsData(const std::list<RsGxsGroupId>* groupIds)
|
bool p3GxsTrans::requestGroupsData(const std::list<RsGxsGroupId>* groupIds)
|
||||||
{
|
{
|
||||||
// std::cout << "p3GxsMails::requestGroupsList()" << std::endl;
|
// std::cout << "p3GxsTrans::requestGroupsList()" << std::endl;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
if(!groupIds) getTokenService()->requestGroupInfo(token, 0xcaca, opts);
|
if(!groupIds) getTokenService()->requestGroupInfo(token, 0xcaca, opts);
|
||||||
@ -397,26 +398,26 @@ bool p3GxsMails::requestGroupsData(const std::list<RsGxsGroupId>* groupIds)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::handleEcryptedMail(const RsGxsMailItem* mail)
|
bool p3GxsTrans::handleEcryptedMail(const RsGxsTransMailItem* mail)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::handleEcryptedMail(...)" << std::endl;
|
std::cout << "p3GxsTrans::handleEcryptedMail(...)" << std::endl;
|
||||||
|
|
||||||
std::set<RsGxsId> decryptIds;
|
std::set<RsGxsId> decryptIds;
|
||||||
std::list<RsGxsId> ownIds;
|
std::list<RsGxsId> ownIds;
|
||||||
idService.getOwnIds(ownIds);
|
mIdService.getOwnIds(ownIds);
|
||||||
for(auto it = ownIds.begin(); it != ownIds.end(); ++it)
|
for(auto it = ownIds.begin(); it != ownIds.end(); ++it)
|
||||||
if(mail->maybeRecipient(*it)) decryptIds.insert(*it);
|
if(mail->maybeRecipient(*it)) decryptIds.insert(*it);
|
||||||
|
|
||||||
// Hint match none of our own ids
|
// Hint match none of our own ids
|
||||||
if(decryptIds.empty())
|
if(decryptIds.empty())
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::handleEcryptedMail(...) hint doesn't match" << std::endl;
|
std::cout << "p3GxsTrans::handleEcryptedMail(...) hint doesn't match" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mail->cryptoType)
|
switch (mail->cryptoType)
|
||||||
{
|
{
|
||||||
case RsGxsMailEncryptionMode::CLEAR_TEXT:
|
case RsGxsTransEncryptionMode::CLEAR_TEXT:
|
||||||
{
|
{
|
||||||
uint16_t csri = 0;
|
uint16_t csri = 0;
|
||||||
uint32_t off = 0;
|
uint32_t off = 0;
|
||||||
@ -428,7 +429,7 @@ bool p3GxsMails::handleEcryptedMail(const RsGxsMailItem* mail)
|
|||||||
return dispatchDecryptedMail( mail->meta.mAuthorId, mail->recipientHint,
|
return dispatchDecryptedMail( mail->meta.mAuthorId, mail->recipientHint,
|
||||||
&mail->payload[0], mail->payload.size() );
|
&mail->payload[0], mail->payload.size() );
|
||||||
}
|
}
|
||||||
case RsGxsMailEncryptionMode::RSA:
|
case RsGxsTransEncryptionMode::RSA:
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for( std::set<RsGxsId>::const_iterator it = decryptIds.begin();
|
for( std::set<RsGxsId>::const_iterator it = decryptIds.begin();
|
||||||
@ -438,7 +439,7 @@ bool p3GxsMails::handleEcryptedMail(const RsGxsMailItem* mail)
|
|||||||
uint8_t* decrypted_data = NULL;
|
uint8_t* decrypted_data = NULL;
|
||||||
uint32_t decrypted_data_size = 0;
|
uint32_t decrypted_data_size = 0;
|
||||||
uint32_t decryption_error;
|
uint32_t decryption_error;
|
||||||
if( idService.decryptData( &mail->payload[0],
|
if( mIdService.decryptData( &mail->payload[0],
|
||||||
mail->payload.size(), decrypted_data,
|
mail->payload.size(), decrypted_data,
|
||||||
decrypted_data_size, decryptId,
|
decrypted_data_size, decryptId,
|
||||||
decryption_error ) )
|
decryption_error ) )
|
||||||
@ -456,108 +457,108 @@ bool p3GxsMails::handleEcryptedMail(const RsGxsMailItem* mail)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::dispatchDecryptedMail( const RsGxsId& authorId,
|
bool p3GxsTrans::dispatchDecryptedMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& decryptId,
|
const RsGxsId& decryptId,
|
||||||
const uint8_t* decrypted_data,
|
const uint8_t* decrypted_data,
|
||||||
uint32_t decrypted_data_size )
|
uint32_t decrypted_data_size )
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::dispatchDecryptedMail(, , " << decrypted_data_size
|
std::cout << "p3GxsTrans::dispatchDecryptedMail(, , " << decrypted_data_size
|
||||||
<< ")" << std::endl;
|
<< ")" << std::endl;
|
||||||
|
|
||||||
uint16_t csri = 0;
|
uint16_t csri = 0;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
if(!getRawUInt16( decrypted_data, decrypted_data_size, &offset, &csri))
|
if(!getRawUInt16( decrypted_data, decrypted_data_size, &offset, &csri))
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::dispatchDecryptedMail(...) (EE) fatal error "
|
std::cerr << "p3GxsTrans::dispatchDecryptedMail(...) (EE) fatal error "
|
||||||
<< "deserializing service type, something really wrong is "
|
<< "deserializing service type, something really wrong is "
|
||||||
<< "happening!" << std::endl;
|
<< "happening!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GxsMailSubServices rsrvc = static_cast<GxsMailSubServices>(csri);
|
GxsTransSubServices rsrvc = static_cast<GxsTransSubServices>(csri);
|
||||||
|
|
||||||
RsNxsMailPresignedReceipt* receipt = new RsNxsMailPresignedReceipt();
|
RsNxsTransPresignedReceipt* receipt = new RsNxsTransPresignedReceipt();
|
||||||
uint32_t rcptsize = decrypted_data_size;
|
uint32_t rcptsize = decrypted_data_size;
|
||||||
if(!receipt->deserialize(decrypted_data, rcptsize, offset))
|
if(!receipt->deserialize(decrypted_data, rcptsize, offset))
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::dispatchDecryptedMail(...) (EE) fatal error "
|
std::cerr << "p3GxsTrans::dispatchDecryptedMail(...) (EE) fatal error "
|
||||||
<< "deserializing presigned return receipt , something really"
|
<< "deserializing presigned return receipt , something really"
|
||||||
<< " wrong is happening!" << std::endl;
|
<< " wrong is happening!" << std::endl;
|
||||||
delete receipt;
|
delete receipt;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::cout << "p3GxsMails::dispatchDecryptedMail(...) dispatching receipt "
|
std::cout << "p3GxsTrans::dispatchDecryptedMail(...) dispatching receipt "
|
||||||
<< "with: msgId: " << receipt->msgId << std::endl;
|
<< "with: msgId: " << receipt->msgId << std::endl;
|
||||||
|
|
||||||
std::vector<RsNxsMsg*> rcct; rcct.push_back(receipt);
|
std::vector<RsNxsMsg*> rcct; rcct.push_back(receipt);
|
||||||
RsGenExchange::notifyNewMessages(rcct);
|
RsGenExchange::notifyNewMessages(rcct);
|
||||||
|
|
||||||
GxsMailsClient* recipientService = NULL;
|
GxsTransClient* recipientService = NULL;
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(servClientsMutex);
|
RS_STACK_MUTEX(mServClientsMutex);
|
||||||
recipientService = servClients[rsrvc];
|
recipientService = mServClients[rsrvc];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(recipientService)
|
if(recipientService)
|
||||||
return recipientService->receiveGxsMail( authorId, decryptId,
|
return recipientService->receiveGxsTransMail(
|
||||||
&decrypted_data[offset],
|
authorId, decryptId, &decrypted_data[offset],
|
||||||
decrypted_data_size-offset );
|
decrypted_data_size-offset );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::dispatchReceivedMail(...) "
|
std::cerr << "p3GxsTrans::dispatchReceivedMail(...) "
|
||||||
<< "got message for unknown service: "
|
<< "got message for unknown service: "
|
||||||
<< csri << std::endl;
|
<< csri << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
void p3GxsTrans::processOutgoingRecord(OutgoingRecord& pr)
|
||||||
{
|
{
|
||||||
//std::cout << "p3GxsMails::processRecord(...)" << std::endl;
|
//std::cout << "p3GxsTrans::processRecord(...)" << std::endl;
|
||||||
|
|
||||||
switch (pr.status)
|
switch (pr.status)
|
||||||
{
|
{
|
||||||
case GxsMailStatus::PENDING_PROCESSING:
|
case GxsTransSendStatus::PENDING_PROCESSING:
|
||||||
{
|
{
|
||||||
pr.mailItem.saltRecipientHint(pr.recipient);
|
pr.mailItem.saltRecipientHint(pr.recipient);
|
||||||
pr.mailItem.saltRecipientHint(RsGxsId::random());
|
pr.mailItem.saltRecipientHint(RsGxsId::random());
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_PREFERRED_GROUP:
|
case GxsTransSendStatus::PENDING_PREFERRED_GROUP:
|
||||||
{
|
{
|
||||||
if(preferredGroupId.isNull())
|
if(mPreferredGroupId.isNull())
|
||||||
{
|
{
|
||||||
requestGroupsData();
|
requestGroupsData();
|
||||||
pr.status = GxsMailStatus::PENDING_PREFERRED_GROUP;
|
pr.status = GxsTransSendStatus::PENDING_PREFERRED_GROUP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr.mailItem.meta.mGroupId = preferredGroupId;
|
pr.mailItem.meta.mGroupId = mPreferredGroupId;
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_RECEIPT_CREATE:
|
case GxsTransSendStatus::PENDING_RECEIPT_CREATE:
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt grcpt;
|
RsGxsTransPresignedReceipt grcpt;
|
||||||
grcpt.meta = pr.mailItem.meta;
|
grcpt.meta = pr.mailItem.meta;
|
||||||
grcpt.meta.mPublishTs = time(NULL);
|
grcpt.meta.mPublishTs = time(NULL);
|
||||||
grcpt.mailId = pr.mailItem.mailId;
|
grcpt.mailId = pr.mailItem.mailId;
|
||||||
uint32_t groff = 0, grsz = grcpt.size();
|
uint32_t groff = 0, grsz = grcpt.serial_size();
|
||||||
std::vector<uint8_t> grsrz;
|
std::vector<uint8_t> grsrz;
|
||||||
grsrz.resize(grsz);
|
grsrz.resize(grsz);
|
||||||
grcpt.serialize(&grsrz[0], grsz, groff);
|
grcpt.serialize(&grsrz[0], grsz, groff);
|
||||||
|
|
||||||
pr.presignedReceipt.grpId = preferredGroupId;
|
pr.presignedReceipt.grpId = mPreferredGroupId;
|
||||||
pr.presignedReceipt.metaData = new RsGxsMsgMetaData();
|
pr.presignedReceipt.metaData = new RsGxsMsgMetaData();
|
||||||
*pr.presignedReceipt.metaData = grcpt.meta;
|
*pr.presignedReceipt.metaData = grcpt.meta;
|
||||||
pr.presignedReceipt.msg.setBinData(&grsrz[0], grsz);
|
pr.presignedReceipt.msg.setBinData(&grsrz[0], grsz);
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_RECEIPT_SIGNATURE:
|
case GxsTransSendStatus::PENDING_RECEIPT_SIGNATURE:
|
||||||
{
|
{
|
||||||
switch (RsGenExchange::createMessage(&pr.presignedReceipt))
|
switch (RsGenExchange::createMessage(&pr.presignedReceipt))
|
||||||
{
|
{
|
||||||
case CREATE_SUCCESS: break;
|
case CREATE_SUCCESS: break;
|
||||||
case CREATE_FAIL_TRY_LATER:
|
case CREATE_FAIL_TRY_LATER:
|
||||||
pr.status = GxsMailStatus::PENDING_RECEIPT_CREATE;
|
pr.status = GxsTransSendStatus::PENDING_RECEIPT_CREATE;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
pr.status = GxsMailStatus::FAILED_RECEIPT_SIGNATURE;
|
pr.status = GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE;
|
||||||
goto processingFailed;
|
goto processingFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +567,7 @@ void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
|||||||
pr.presignedReceipt.metaData->serialise(&srx[0], &metaSize);
|
pr.presignedReceipt.metaData->serialise(&srx[0], &metaSize);
|
||||||
pr.presignedReceipt.meta.setBinData(&srx[0], metaSize);
|
pr.presignedReceipt.meta.setBinData(&srx[0], metaSize);
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_PAYLOAD_CREATE:
|
case GxsTransSendStatus::PENDING_PAYLOAD_CREATE:
|
||||||
{
|
{
|
||||||
uint16_t serv = static_cast<uint16_t>(pr.clientService);
|
uint16_t serv = static_cast<uint16_t>(pr.clientService);
|
||||||
uint32_t rcptsize = pr.presignedReceipt.serial_size();
|
uint32_t rcptsize = pr.presignedReceipt.serial_size();
|
||||||
@ -579,23 +580,23 @@ void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
|||||||
offset += rcptsize;
|
offset += rcptsize;
|
||||||
memcpy(&pr.mailItem.payload[offset], &pr.mailData[0], datasize);
|
memcpy(&pr.mailItem.payload[offset], &pr.mailData[0], datasize);
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_PAYLOAD_ENCRYPT:
|
case GxsTransSendStatus::PENDING_PAYLOAD_ENCRYPT:
|
||||||
{
|
{
|
||||||
switch (pr.mailItem.cryptoType)
|
switch (pr.mailItem.cryptoType)
|
||||||
{
|
{
|
||||||
case RsGxsMailEncryptionMode::CLEAR_TEXT:
|
case RsGxsTransEncryptionMode::CLEAR_TEXT:
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::sendMail(...) you are sending a mail "
|
std::cerr << "p3GxsTrans::sendMail(...) you are sending a mail "
|
||||||
<< "without encryption, everyone can read it!"
|
<< "without encryption, everyone can read it!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RsGxsMailEncryptionMode::RSA:
|
case RsGxsTransEncryptionMode::RSA:
|
||||||
{
|
{
|
||||||
uint8_t* encryptedData = NULL;
|
uint8_t* encryptedData = NULL;
|
||||||
uint32_t encryptedSize = 0;
|
uint32_t encryptedSize = 0;
|
||||||
uint32_t encryptError = 0;
|
uint32_t encryptError = 0;
|
||||||
if( idService.encryptData( &pr.mailItem.payload[0],
|
if( mIdService.encryptData( &pr.mailItem.payload[0],
|
||||||
pr.mailItem.payload.size(),
|
pr.mailItem.payload.size(),
|
||||||
encryptedData, encryptedSize,
|
encryptedData, encryptedSize,
|
||||||
pr.recipient, encryptError, true ) )
|
pr.recipient, encryptError, true ) )
|
||||||
@ -608,25 +609,25 @@ void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsMails::sendMail(...) RSA encryption failed! "
|
std::cerr << "p3GxsTrans::sendMail(...) RSA encryption failed! "
|
||||||
<< "error_status: " << encryptError << std::endl;
|
<< "error_status: " << encryptError << std::endl;
|
||||||
pr.status = GxsMailStatus::FAILED_ENCRYPTION;
|
pr.status = GxsTransSendStatus::FAILED_ENCRYPTION;
|
||||||
goto processingFailed;
|
goto processingFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RsGxsMailEncryptionMode::UNDEFINED_ENCRYPTION:
|
case RsGxsTransEncryptionMode::UNDEFINED_ENCRYPTION:
|
||||||
default:
|
default:
|
||||||
std::cerr << "p3GxsMails::sendMail(...) attempt to send mail with "
|
std::cerr << "p3GxsTrans::sendMail(...) attempt to send mail with "
|
||||||
<< "wrong EncryptionMode: "
|
<< "wrong EncryptionMode: "
|
||||||
<< static_cast<uint>(pr.mailItem.cryptoType)
|
<< static_cast<uint>(pr.mailItem.cryptoType)
|
||||||
<< " dropping mail!" << std::endl;
|
<< " dropping mail!" << std::endl;
|
||||||
pr.status = GxsMailStatus::FAILED_ENCRYPTION;
|
pr.status = GxsTransSendStatus::FAILED_ENCRYPTION;
|
||||||
goto processingFailed;
|
goto processingFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case GxsMailStatus::PENDING_PUBLISH:
|
case GxsTransSendStatus::PENDING_PUBLISH:
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::sendEmail(...) sending mail to: "
|
std::cout << "p3GxsTrans::sendEmail(...) sending mail to: "
|
||||||
<< pr.recipient
|
<< pr.recipient
|
||||||
<< " with cryptoType: "
|
<< " with cryptoType: "
|
||||||
<< static_cast<uint>(pr.mailItem.cryptoType)
|
<< static_cast<uint>(pr.mailItem.cryptoType)
|
||||||
@ -636,38 +637,38 @@ void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
publishMsg(token, new RsGxsMailItem(pr.mailItem));
|
publishMsg(token, new RsGxsTransMailItem(pr.mailItem));
|
||||||
pr.status = GxsMailStatus::PENDING_RECEIPT_RECEIVE;
|
pr.status = GxsTransSendStatus::PENDING_RECEIPT_RECEIVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case GxsMailStatus::PENDING_TRANSFER:
|
//case GxsTransSendStatus::PENDING_TRANSFER:
|
||||||
case GxsMailStatus::PENDING_RECEIPT_RECEIVE:
|
case GxsTransSendStatus::PENDING_RECEIPT_RECEIVE:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(mIngoingMutex);
|
||||||
auto range = ingoingQueue.equal_range(pr.mailItem.mailId);
|
auto range = mIngoingQueue.equal_range(pr.mailItem.mailId);
|
||||||
for( auto it = range.first; it != range.second; ++it)
|
for( auto it = range.first; it != range.second; ++it)
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt* rt =
|
RsGxsTransPresignedReceipt* rt =
|
||||||
dynamic_cast<RsGxsMailPresignedReceipt*>(it->second);
|
dynamic_cast<RsGxsTransPresignedReceipt*>(it->second);
|
||||||
if(rt && idService.isOwnId(rt->meta.mAuthorId))
|
if(rt && mIdService.isOwnId(rt->meta.mAuthorId))
|
||||||
{
|
{
|
||||||
ingoingQueue.erase(it); delete rt;
|
mIngoingQueue.erase(it); delete rt;
|
||||||
pr.status = GxsMailStatus::RECEIPT_RECEIVED;
|
pr.status = GxsTransSendStatus::RECEIPT_RECEIVED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Resend message if older then treshold
|
// TODO: Resend message if older then treshold
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailStatus::RECEIPT_RECEIVED:
|
case GxsTransSendStatus::RECEIPT_RECEIVED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
processingFailed:
|
processingFailed:
|
||||||
case GxsMailStatus::FAILED_RECEIPT_SIGNATURE:
|
case GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE:
|
||||||
case GxsMailStatus::FAILED_ENCRYPTION:
|
case GxsTransSendStatus::FAILED_ENCRYPTION:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::processRecord(" << pr.mailItem.mailId
|
std::cout << "p3GxsTrans::processRecord(" << pr.mailItem.mailId
|
||||||
<< ") failed with: " << static_cast<uint>(pr.status)
|
<< ") failed with: " << static_cast<uint>(pr.status)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
break;
|
break;
|
||||||
@ -675,21 +676,21 @@ processingFailed:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::notifyClientService(const OutgoingRecord& pr)
|
void p3GxsTrans::notifyClientService(const OutgoingRecord& pr)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(servClientsMutex);
|
RS_STACK_MUTEX(mServClientsMutex);
|
||||||
auto it = servClients.find(pr.clientService);
|
auto it = mServClients.find(pr.clientService);
|
||||||
if( it != servClients.end())
|
if( it != mServClients.end())
|
||||||
{
|
{
|
||||||
GxsMailsClient* serv(it->second);
|
GxsTransClient* serv(it->second);
|
||||||
if(serv)
|
if(serv)
|
||||||
{
|
{
|
||||||
serv->notifySendMailStatus(pr.mailItem, pr.status);
|
serv->notifyGxsTransSendStatus(pr.mailItem.mailId, pr.status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "p3GxsMails::processRecord(...) (EE) processed"
|
std::cerr << "p3GxsTrans::processRecord(...) (EE) processed"
|
||||||
<< " mail for unkown service: "
|
<< " mail for unkown service: "
|
||||||
<< static_cast<uint32_t>(pr.clientService)
|
<< static_cast<uint32_t>(pr.clientService)
|
||||||
<< " fatally failed with: "
|
<< " fatally failed with: "
|
||||||
@ -697,74 +698,74 @@ void p3GxsMails::notifyClientService(const OutgoingRecord& pr)
|
|||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
RsSerialiser* p3GxsMails::setupSerialiser()
|
RsSerialiser* p3GxsTrans::setupSerialiser()
|
||||||
{
|
{
|
||||||
RsSerialiser* rss = new RsSerialiser;
|
RsSerialiser* rss = new RsSerialiser;
|
||||||
rss->addSerialType(new RsGxsMailSerializer);
|
rss->addSerialType(new RsGxsTransSerializer);
|
||||||
return rss;
|
return rss;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::saveList(bool &cleanup, std::list<RsItem *>& saveList)
|
bool p3GxsTrans::saveList(bool &cleanup, std::list<RsItem *>& saveList)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::saveList(...)" << saveList.size() << " "
|
std::cout << "p3GxsTrans::saveList(...)" << saveList.size() << " "
|
||||||
<< ingoingQueue.size() << " " << outgoingQueue.size()
|
<< mIngoingQueue.size() << " " << mOutgoingQueue.size()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
outgoingMutex.lock();
|
mOutgoingMutex.lock();
|
||||||
ingoingMutex.lock();
|
mIngoingMutex.lock();
|
||||||
|
|
||||||
for ( auto& kv : outgoingQueue ) saveList.push_back(&kv.second);
|
for ( auto& kv : mOutgoingQueue ) saveList.push_back(&kv.second);
|
||||||
for ( auto& kv : ingoingQueue ) saveList.push_back(kv.second);
|
for ( auto& kv : mIngoingQueue ) saveList.push_back(kv.second);
|
||||||
|
|
||||||
std::cout << "p3GxsMails::saveList(...)" << saveList.size() << " "
|
std::cout << "p3GxsTrans::saveList(...)" << saveList.size() << " "
|
||||||
<< ingoingQueue.size() << " " << outgoingQueue.size()
|
<< mIngoingQueue.size() << " " << mOutgoingQueue.size()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
cleanup = false;
|
cleanup = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsMails::saveDone()
|
void p3GxsTrans::saveDone()
|
||||||
{
|
{
|
||||||
outgoingMutex.unlock();
|
mOutgoingMutex.unlock();
|
||||||
ingoingMutex.unlock();
|
mIngoingMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsMails::loadList(std::list<RsItem *>&loadList)
|
bool p3GxsTrans::loadList(std::list<RsItem *>&loadList)
|
||||||
{
|
{
|
||||||
std::cout << "p3GxsMails::loadList(...) " << loadList.size() << " "
|
std::cout << "p3GxsTrans::loadList(...) " << loadList.size() << " "
|
||||||
<< ingoingQueue.size() << " " << outgoingQueue.size()
|
<< mIngoingQueue.size() << " " << mOutgoingQueue.size()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
for(auto& v : loadList)
|
for(auto& v : loadList)
|
||||||
switch(static_cast<GxsMailItemsSubtypes>(v->PacketSubType()))
|
switch(static_cast<GxsTransItemsSubtypes>(v->PacketSubType()))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
{
|
{
|
||||||
RsGxsMailBaseItem* mi = dynamic_cast<RsGxsMailBaseItem*>(v);
|
RsGxsTransBaseItem* mi = dynamic_cast<RsGxsTransBaseItem*>(v);
|
||||||
if(mi)
|
if(mi)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(mIngoingMutex);
|
||||||
ingoingQueue.insert(inMap::value_type(mi->mailId, mi));
|
mIngoingQueue.insert(inMap::value_type(mi->mailId, mi));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM:
|
case GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM:
|
||||||
{
|
{
|
||||||
OutgoingRecord* ot = dynamic_cast<OutgoingRecord*>(v);
|
OutgoingRecord* ot = dynamic_cast<OutgoingRecord*>(v);
|
||||||
if(ot)
|
if(ot)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(outgoingMutex);
|
RS_STACK_MUTEX(mOutgoingMutex);
|
||||||
outgoingQueue.insert(
|
mOutgoingQueue.insert(
|
||||||
prMap::value_type(ot->mailItem.mailId, *ot));
|
prMap::value_type(ot->mailItem.mailId, *ot));
|
||||||
}
|
}
|
||||||
delete v;
|
delete v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_GROUP:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_GROUP:
|
||||||
default:
|
default:
|
||||||
std::cerr << "p3GxsMails::loadList(...) (EE) got item with "
|
std::cerr << "p3GxsTrans::loadList(...) (EE) got item with "
|
||||||
<< "unhandled type: "
|
<< "unhandled type: "
|
||||||
<< static_cast<uint>(v->PacketSubType())
|
<< static_cast<uint>(v->PacketSubType())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -772,8 +773,8 @@ bool p3GxsMails::loadList(std::list<RsItem *>&loadList)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "p3GxsMails::loadList(...) " << loadList.size() << " "
|
std::cout << "p3GxsTrans::loadList(...) " << loadList.size() << " "
|
||||||
<< ingoingQueue.size() << " " << outgoingQueue.size()
|
<< mIngoingQueue.size() << " " << mOutgoingQueue.size()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
@ -23,102 +23,103 @@
|
|||||||
|
|
||||||
#include "retroshare/rsgxsifacetypes.h" // For RsGxsId, RsGxsCircleId
|
#include "retroshare/rsgxsifacetypes.h" // For RsGxsId, RsGxsCircleId
|
||||||
#include "gxs/gxstokenqueue.h" // For GxsTokenQueue
|
#include "gxs/gxstokenqueue.h" // For GxsTokenQueue
|
||||||
#include "serialiser/rsgxsmailitems.h" // For RS_SERVICE_TYPE_GXS_MAIL
|
#include "gxstrans/p3gxstransitems.h"
|
||||||
#include "services/p3idservice.h" // For p3IdService
|
#include "services/p3idservice.h" // For p3IdService
|
||||||
#include "util/rsthreads.h"
|
#include "util/rsthreads.h"
|
||||||
|
|
||||||
struct p3GxsMails;
|
struct p3GxsTrans;
|
||||||
|
|
||||||
/// Services who want to make use of p3GxsMails should inherit this struct
|
/// Services who want to make use of p3GxsTrans should inherit this struct
|
||||||
struct GxsMailsClient
|
struct GxsTransClient
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This will be called by p3GxsMails to dispatch mails to the subservice
|
* This will be called by p3GxsTrans to dispatch mails to the subservice
|
||||||
* @param authorId message sender
|
* @param authorId message sender
|
||||||
* @param decryptId recipient id
|
* @param decryptId recipient id
|
||||||
* @param data buffer containing the decrypted data
|
* @param data buffer containing the decrypted data
|
||||||
* @param dataSize size of the buffer
|
* @param dataSize size of the buffer
|
||||||
* @return true if dispatching goes fine, false otherwise
|
* @return true if dispatching goes fine, false otherwise
|
||||||
*/
|
*/
|
||||||
virtual bool receiveGxsMail( const RsGxsId& authorId,
|
virtual bool receiveGxsTransMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& recipientId,
|
const RsGxsId& recipientId,
|
||||||
const uint8_t* data, uint32_t dataSize ) = 0;
|
const uint8_t* data, uint32_t dataSize
|
||||||
|
) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will be called by p3GxsMails to notify the subservice about the
|
* This will be called by p3GxsTrans to notify the subservice about the
|
||||||
* status of a sent email.
|
* status of a sent email.
|
||||||
* @param originalMessage message for with the notification is made
|
* @param originalMessage message for with the notification is made
|
||||||
* @param status the new status of the message
|
* @param status the new status of the message
|
||||||
* @return true if notification goes fine, false otherwise (ignored ATM)
|
* @return true if notification goes fine, false otherwise (ignored ATM)
|
||||||
*/
|
*/
|
||||||
virtual bool notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
virtual bool notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||||
GxsMailStatus status ) = 0;
|
GxsTransSendStatus status ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief p3GxsMails is a mail delivery service based on GXS.
|
* @brief p3GxsTrans is a mail delivery service based on GXS.
|
||||||
* p3GxsMails is capable of asynchronous mail delivery and acknowledgement.
|
* p3GxsTrans is capable of asynchronous mail delivery and acknowledgement.
|
||||||
* p3GxsMails is meant to be capable of multiple encryption options,
|
* p3GxsTrans is meant to be capable of multiple encryption options,
|
||||||
* @see RsGxsMailEncryptionMode at moment messages are encrypted using RSA
|
* @see RsGxsTransEncryptionMode at moment messages are encrypted using RSA
|
||||||
* unless the user ask for them being sent in clear text ( this is not supposed
|
* unless the user ask for them being sent in clear text ( this is not supposed
|
||||||
* to happen in non testing environment so warnings and stack traces are printed
|
* to happen in non testing environment so warnings and stack traces are printed
|
||||||
* in the log if an attempt to send something in clear text is made ).
|
* in the log if an attempt to send something in clear text is made ).
|
||||||
* p3GxsMails try to hide metadata so the travelling message signed by the author
|
* p3GxsTrans try to hide metadata so the travelling message signed by the author
|
||||||
* but the recipient is not disclosed, instead to avoid everyone trying to
|
* but the recipient is not disclosed, instead to avoid everyone trying to
|
||||||
* decrypt every message a hint has been introduced, the hint is calculated in a
|
* decrypt every message a hint has been introduced, the hint is calculated in a
|
||||||
* way that one can easily prove that a message is not destined to someone, but
|
* way that one can easily prove that a message is not destined to someone, but
|
||||||
* cannot prove the message is destined to someone
|
* cannot prove the message is destined to someone
|
||||||
* @see RsGxsMailItem::recipientsHint for more details.
|
* @see RsGxsTransMailItem::recipientHint for more details.
|
||||||
* p3GxsMails expose a simple API to send and receive mails, the API also
|
* p3GxsTrans expose a simple API to send and receive mails, the API also
|
||||||
* provide notification for the sending mail status @see sendMail(...),
|
* provide notification for the sending mail status @see sendMail(...),
|
||||||
* @see querySendMailStatus(...), @see registerGxsMailsClient(...),
|
* @see querySendStatus(...), @see registerGxsTransClient(...),
|
||||||
* @see GxsMailsClient::receiveGxsMail(...),
|
* @see GxsTransClient::receiveGxsTransMail(...),
|
||||||
* @see GxsMailsClient::notifySendMailStatus(...).
|
* @see GxsTransClient::notifyGxsTransSendStatus(...).
|
||||||
*/
|
*/
|
||||||
struct p3GxsMails : RsGenExchange, GxsTokenQueue, p3Config
|
struct p3GxsTrans : RsGenExchange, GxsTokenQueue, p3Config
|
||||||
{
|
{
|
||||||
p3GxsMails( RsGeneralDataService* gds, RsNetworkExchangeService* nes,
|
p3GxsTrans( RsGeneralDataService* gds, RsNetworkExchangeService* nes,
|
||||||
p3IdService& identities ) :
|
p3IdService& identities ) :
|
||||||
RsGenExchange( gds, nes, new RsGxsMailSerializer(),
|
RsGenExchange( gds, nes, new RsGxsTransSerializer(),
|
||||||
RS_SERVICE_TYPE_GXS_MAIL, &identities,
|
RS_SERVICE_TYPE_GXS_TRANS, &identities,
|
||||||
AuthenPolicy(), GXS_STORAGE_PERIOD ),
|
AuthenPolicy(), GXS_STORAGE_PERIOD ),
|
||||||
GxsTokenQueue(this), idService(identities),
|
GxsTokenQueue(this), mIdService(identities),
|
||||||
servClientsMutex("p3GxsMails client services map mutex"),
|
mServClientsMutex("p3GxsTrans client services map mutex"),
|
||||||
outgoingMutex("p3GxsMails outgoing queue map mutex"),
|
mOutgoingMutex("p3GxsTrans outgoing queue map mutex"),
|
||||||
ingoingMutex("p3GxsMails ingoing queue map mutex") {}
|
mIngoingMutex("p3GxsTrans ingoing queue map mutex") {}
|
||||||
~p3GxsMails();
|
~p3GxsTrans();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an email to recipient, in the process author of the email is
|
* Send an email to recipient, in the process author of the email is
|
||||||
* disclosed to the network (because the sent GXS item is signed), while
|
* disclosed to the network (because the sent GXS item is signed), while
|
||||||
* recipient is not @see RsGxsMailBaseItem::recipientsHint for details on
|
* recipient is not @see RsGxsTransMailItem::recipientHint for details on
|
||||||
* recipient protection.
|
* recipient protection.
|
||||||
* This method is part of the public interface of this service.
|
* This method is part of the public interface of this service.
|
||||||
* @return true if the mail will be sent, false if not
|
* @return true if the mail will be sent, false if not
|
||||||
*/
|
*/
|
||||||
bool sendMail( RsGxsMailId& mailId,
|
bool sendMail( RsGxsTransId& mailId,
|
||||||
GxsMailSubServices service,
|
GxsTransSubServices service,
|
||||||
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, uint32_t size,
|
||||||
RsGxsMailEncryptionMode cm = RsGxsMailEncryptionMode::RSA
|
RsGxsTransEncryptionMode cm = RsGxsTransEncryptionMode::RSA
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is part of the public interface of this service.
|
* This method is part of the public interface of this service.
|
||||||
* @return false if mail is not found in outgoing queue, true otherwise
|
* @return false if mail is not found in outgoing queue, true otherwise
|
||||||
*/
|
*/
|
||||||
bool querySendMailStatus( RsGxsMailId mailId, GxsMailStatus& st );
|
bool querySendStatus( RsGxsTransId mailId, GxsTransSendStatus& st );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a client service to p3GxsMails to receive mails via
|
* Register a client service to p3GxsTrans to receive mails via
|
||||||
* GxsMailsClient::receiveGxsMail(...) callback
|
* GxsTransClient::receiveGxsTransMail(...) callback
|
||||||
* This method is part of the public interface of this service.
|
* This method is part of the public interface of this service.
|
||||||
*/
|
*/
|
||||||
void registerGxsMailsClient( GxsMailSubServices serviceType,
|
void registerGxsTransClient( GxsTransSubServices serviceType,
|
||||||
GxsMailsClient* service );
|
GxsTransClient* service );
|
||||||
|
|
||||||
/// @see RsGenExchange::getServiceInfo()
|
/// @see RsGenExchange::getServiceInfo()
|
||||||
virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_MAIL, "GXS Mails", 0, 1, 0, 1 ); }
|
virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Time interval of inactivity before a distribution group is unsubscribed.
|
/** Time interval of inactivity before a distribution group is unsubscribed.
|
||||||
@ -152,14 +153,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Store the id of the preferred GXS group to send emails
|
/// Store the id of the preferred GXS group to send emails
|
||||||
RsGxsGroupId preferredGroupId;
|
RsGxsGroupId mPreferredGroupId;
|
||||||
|
|
||||||
/// Used for items {de,en}cryption
|
/// Used for items {de,en}cryption
|
||||||
p3IdService& idService;
|
p3IdService& mIdService;
|
||||||
|
|
||||||
/// Stores pointers to client services to notify them about new mails
|
/// Stores pointers to client services to notify them about new mails
|
||||||
std::map<GxsMailSubServices, GxsMailsClient*> servClients;
|
std::map<GxsTransSubServices, GxsTransClient*> mServClients;
|
||||||
RsMutex servClientsMutex;
|
RsMutex mServClientsMutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Keep track of outgoing mails.
|
* @brief Keep track of outgoing mails.
|
||||||
@ -167,9 +168,9 @@ private:
|
|||||||
* receipt has been received or sending is considered definetly failed.
|
* receipt has been received or sending is considered definetly failed.
|
||||||
* Items are saved in config for consistence accross RetroShare shutdowns.
|
* Items are saved in config for consistence accross RetroShare shutdowns.
|
||||||
*/
|
*/
|
||||||
typedef std::map<RsGxsMailId, OutgoingRecord> prMap;
|
typedef std::map<RsGxsTransId, OutgoingRecord> prMap;
|
||||||
prMap outgoingQueue;
|
prMap mOutgoingQueue;
|
||||||
RsMutex outgoingMutex;
|
RsMutex mOutgoingMutex;
|
||||||
void processOutgoingRecord(OutgoingRecord& r);
|
void processOutgoingRecord(OutgoingRecord& r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,9 +182,9 @@ private:
|
|||||||
* item to not being processed and memleaked multimap is used instead of map
|
* item to not being processed and memleaked multimap is used instead of map
|
||||||
* for incoming queue.
|
* for incoming queue.
|
||||||
*/
|
*/
|
||||||
typedef std::unordered_multimap<RsGxsMailId, RsGxsMailBaseItem*> inMap;
|
typedef std::unordered_multimap<RsGxsTransId, RsGxsTransBaseItem*> inMap;
|
||||||
inMap ingoingQueue;
|
inMap mIngoingQueue;
|
||||||
RsMutex ingoingMutex;
|
RsMutex mIngoingMutex;
|
||||||
|
|
||||||
/// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type)
|
/// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type)
|
||||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||||
@ -223,11 +224,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool inline supersedePreferredGroup(const RsGxsGroupId& potentialGrId)
|
bool inline supersedePreferredGroup(const RsGxsGroupId& potentialGrId)
|
||||||
{
|
{
|
||||||
if(preferredGroupId < potentialGrId)
|
if(mPreferredGroupId < potentialGrId)
|
||||||
{
|
{
|
||||||
std::cerr << "supersedePreferredGroup(...) " << potentialGrId
|
std::cerr << "supersedePreferredGroup(...) " << potentialGrId
|
||||||
<< " supersed " << preferredGroupId << std::endl;
|
<< " supersed " << mPreferredGroupId << std::endl;
|
||||||
preferredGroupId = potentialGrId;
|
mPreferredGroupId = potentialGrId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -241,7 +242,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
/// Decrypt email content and pass it to dispatchDecryptedMail(...)
|
/// Decrypt email content and pass it to dispatchDecryptedMail(...)
|
||||||
bool handleEcryptedMail(const RsGxsMailItem* mail);
|
bool handleEcryptedMail(const RsGxsTransMailItem* mail);
|
||||||
|
|
||||||
/// Dispatch the message to the recipient service
|
/// Dispatch the message to the recipient service
|
||||||
bool dispatchDecryptedMail( const RsGxsId& authorId,
|
bool dispatchDecryptedMail( const RsGxsId& authorId,
|
||||||
@ -252,72 +253,3 @@ private:
|
|||||||
void notifyClientService(const OutgoingRecord& pr);
|
void notifyClientService(const OutgoingRecord& pr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef TEST_RS_GXS_MAIL
|
|
||||||
|
|
||||||
struct TestGxsMailClientService : GxsMailsClient, RsSingleJobThread
|
|
||||||
{
|
|
||||||
TestGxsMailClientService( p3GxsMails& gxsMailService,
|
|
||||||
p3IdService& gxsIdService ) :
|
|
||||||
mailService(gxsMailService), idService(gxsIdService)
|
|
||||||
{
|
|
||||||
mailService.registerGxsMailsClient( GxsMailSubServices::TEST_SERVICE,
|
|
||||||
this );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @see GxsMailsClient::receiveGxsMail(...)
|
|
||||||
virtual bool receiveGxsMail( const RsGxsMailItem& originalMessage,
|
|
||||||
const uint8_t* data, uint32_t dataSize )
|
|
||||||
{
|
|
||||||
std::cout << "TestGxsMailClientService::receiveGxsMail(...) got message"
|
|
||||||
<< " from: " << originalMessage.meta.mAuthorId << std::endl
|
|
||||||
<< "\t>" << std::string((char*)data, dataSize) << "<"
|
|
||||||
<< std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @see GxsMailsClient::notifyMailStatus(...)
|
|
||||||
virtual bool notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
|
||||||
GxsMailStatus status )
|
|
||||||
{
|
|
||||||
std::cout << "TestGxsMailClientService::notifyMailsStatus(...) for: "
|
|
||||||
<< originalMessage.mailId << " status: "
|
|
||||||
<< static_cast<uint>(status) << std::endl;
|
|
||||||
if( status == GxsMailStatus::RECEIPT_RECEIVED )
|
|
||||||
std::cout << "\t It mean Receipt has been Received!" << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @see RsSingleJobThread::run()
|
|
||||||
virtual void run()
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
usleep(10*1000*1000);
|
|
||||||
RsGxsId gxsidA("d0df7474bdde0464679e6ef787890287");
|
|
||||||
RsGxsId gxsidB("d060bea09dfa14883b5e6e517eb580cd");
|
|
||||||
RsGxsMailId mailId = 0;
|
|
||||||
if(idService.isOwnId(gxsidA))
|
|
||||||
{
|
|
||||||
std::string ciao("CiAone!");
|
|
||||||
mailService.sendMail( mailId, GxsMailSubServices::TEST_SERVICE,
|
|
||||||
gxsidA, gxsidB,
|
|
||||||
reinterpret_cast<const uint8_t*>(ciao.data()),
|
|
||||||
ciao.size() );
|
|
||||||
}
|
|
||||||
else if(idService.isOwnId(gxsidB))
|
|
||||||
{
|
|
||||||
std::string ciao("CiBuono!");
|
|
||||||
mailService.sendMail( mailId, GxsMailSubServices::TEST_SERVICE,
|
|
||||||
gxsidB, gxsidA,
|
|
||||||
reinterpret_cast<const uint8_t*>(ciao.data()),
|
|
||||||
ciao.size() );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
p3GxsMails& mailService;
|
|
||||||
p3IdService& idService;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TEST_RS_GXS_MAIL
|
|
||||||
|
|
@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "serialiser/rsgxsmailitems.h"
|
#include "gxstrans/p3gxstransitems.h"
|
||||||
|
|
||||||
const RsGxsId RsGxsMailItem::allRecipientsHint("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
const RsGxsId RsGxsTransMailItem::allRecipientsHint("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
||||||
|
|
||||||
|
|
||||||
bool RsGxsMailBaseItem::serialize(uint8_t* data, uint32_t size,
|
bool RsGxsTransBaseItem::serialize(uint8_t* data, uint32_t size,
|
||||||
uint32_t& offset) const
|
uint32_t& offset) const
|
||||||
{
|
{
|
||||||
bool ok = setRsItemHeader(data+offset, size, PacketId(), size);
|
bool ok = setRsItemHeader(data+offset, size, PacketId(), size);
|
||||||
@ -30,7 +30,7 @@ bool RsGxsMailBaseItem::serialize(uint8_t* data, uint32_t size,
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsMailBaseItem::deserialize(const uint8_t* data, uint32_t& size,
|
bool RsGxsTransBaseItem::deserialize( const uint8_t* data, uint32_t& size,
|
||||||
uint32_t& offset)
|
uint32_t& offset)
|
||||||
{
|
{
|
||||||
void* hdrPtr = const_cast<uint8_t*>(data+offset);
|
void* hdrPtr = const_cast<uint8_t*>(data+offset);
|
||||||
@ -45,42 +45,42 @@ bool RsGxsMailBaseItem::deserialize(const uint8_t* data, uint32_t& size,
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& RsGxsMailBaseItem::print(std::ostream &out, uint16_t)
|
std::ostream& RsGxsTransBaseItem::print(std::ostream &out, uint16_t)
|
||||||
{ return out << " RsGxsMailBaseItem::mailId: " << mailId; }
|
{ return out << __PRETTY_FUNCTION__ << " mailId: " << mailId; }
|
||||||
|
|
||||||
bool RsGxsMailSerializer::serialise(RsItem* item, void* data, uint32_t* size)
|
bool RsGxsTransSerializer::serialise(RsItem* item, void* data, uint32_t* size)
|
||||||
{
|
{
|
||||||
uint32_t itemSize = RsGxsMailSerializer::size(item);
|
uint32_t itemSize = RsGxsTransSerializer::size(item);
|
||||||
if(*size < itemSize)
|
if(*size < itemSize)
|
||||||
{
|
{
|
||||||
std::cout << "RsGxsMailSerializer::serialise(...) failed due to wrong size: "
|
std::cout << __PRETTY_FUNCTION__ << " failed due to wrong size: "
|
||||||
<< size << " < " << itemSize << std::endl;
|
<< size << " < " << itemSize << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* dataPtr = reinterpret_cast<uint8_t*>(data);
|
uint8_t* dataPtr = reinterpret_cast<uint8_t*>(data);
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
switch(static_cast<GxsMailItemsSubtypes>(item->PacketSubType()))
|
switch(static_cast<GxsTransItemsSubtypes>(item->PacketSubType()))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
{
|
{
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
RsGxsMailItem* i = dynamic_cast<RsGxsMailItem*>(item);
|
RsGxsTransMailItem* i = dynamic_cast<RsGxsTransMailItem*>(item);
|
||||||
ok = i && i->serialize(dataPtr, itemSize, offset);
|
ok = i && i->serialize(dataPtr, itemSize, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt* i =
|
RsGxsTransPresignedReceipt* i =
|
||||||
dynamic_cast<RsGxsMailPresignedReceipt*>(item);
|
dynamic_cast<RsGxsTransPresignedReceipt*>(item);
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
ok = i && i->serialize(dataPtr, itemSize, offset);
|
ok = i && i->serialize(dataPtr, itemSize, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_GROUP:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_GROUP:
|
||||||
ok = setRsItemHeader(data, itemSize, item->PacketId(), itemSize);
|
ok = setRsItemHeader(data, itemSize, item->PacketId(), itemSize);
|
||||||
break;
|
break;
|
||||||
case GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM:
|
case GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM:
|
||||||
{
|
{
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
OutgoingRecord* i = dynamic_cast<OutgoingRecord*>(item);
|
OutgoingRecord* i = dynamic_cast<OutgoingRecord*>(item);
|
||||||
@ -96,15 +96,15 @@ bool RsGxsMailSerializer::serialise(RsItem* item, void* data, uint32_t* size)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "RsGxsMailSerializer::serialise(...) failed!" << std::endl;
|
std::cout << __PRETTY_FUNCTION__ << " failed!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingRecord::OutgoingRecord( RsGxsId rec, GxsMailSubServices cs,
|
OutgoingRecord::OutgoingRecord( RsGxsId rec, GxsTransSubServices cs,
|
||||||
const uint8_t* data, uint32_t size ) :
|
const uint8_t* data, uint32_t size ) :
|
||||||
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_MAIL,
|
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_TRANS,
|
||||||
static_cast<uint8_t>(GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM) ),
|
static_cast<uint8_t>(GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM) ),
|
||||||
status(GxsMailStatus::PENDING_PROCESSING), recipient(rec),
|
status(GxsTransSendStatus::PENDING_PROCESSING), recipient(rec),
|
||||||
clientService(cs)
|
clientService(cs)
|
||||||
{
|
{
|
||||||
mailData.resize(size);
|
mailData.resize(size);
|
||||||
@ -113,11 +113,11 @@ OutgoingRecord::OutgoingRecord( RsGxsId rec, GxsMailSubServices cs,
|
|||||||
|
|
||||||
void OutgoingRecord::clear()
|
void OutgoingRecord::clear()
|
||||||
{
|
{
|
||||||
status = GxsMailStatus::UNKNOWN;
|
status = GxsTransSendStatus::UNKNOWN;
|
||||||
recipient.clear();
|
recipient.clear();
|
||||||
mailItem.clear();
|
mailItem.clear();
|
||||||
mailData.clear();
|
mailData.clear();
|
||||||
clientService = GxsMailSubServices::UNKNOWN;
|
clientService = GxsTransSubServices::UNKNOWN;
|
||||||
presignedReceipt.clear();
|
presignedReceipt.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +125,8 @@ std::ostream& OutgoingRecord::print(std::ostream& out, uint16_t)
|
|||||||
{ return out << "TODO: OutgoingRecordItem::print(...)"; }
|
{ return out << "TODO: OutgoingRecordItem::print(...)"; }
|
||||||
|
|
||||||
OutgoingRecord::OutgoingRecord() :
|
OutgoingRecord::OutgoingRecord() :
|
||||||
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_MAIL,
|
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_GXS_TRANS,
|
||||||
static_cast<uint8_t>(GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM) )
|
static_cast<uint8_t>(GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM) )
|
||||||
{ clear();}
|
{ clear();}
|
||||||
|
|
||||||
uint32_t OutgoingRecord::size() const
|
uint32_t OutgoingRecord::size() const
|
||||||
@ -134,7 +134,7 @@ uint32_t OutgoingRecord::size() const
|
|||||||
return 8 + // Header
|
return 8 + // Header
|
||||||
1 + // status
|
1 + // status
|
||||||
recipient.serial_size() +
|
recipient.serial_size() +
|
||||||
mailItem.size() +
|
mailItem.serial_size() +
|
||||||
4 + // sizeof(mailData.size())
|
4 + // sizeof(mailData.size())
|
||||||
mailData.size() +
|
mailData.size() +
|
||||||
2 + // clientService
|
2 + // clientService
|
||||||
@ -154,7 +154,7 @@ bool OutgoingRecord::serialize( uint8_t* data, uint32_t size,
|
|||||||
ok = ok && recipient.serialise(data, size, offset);
|
ok = ok && recipient.serialise(data, size, offset);
|
||||||
|
|
||||||
uint32_t tmpOffset = 0;
|
uint32_t tmpOffset = 0;
|
||||||
uint32_t tmpSize = mailItem.size();
|
uint32_t tmpSize = mailItem.serial_size();
|
||||||
ok = ok && mailItem.serialize(data+offset, tmpSize, tmpOffset)
|
ok = ok && mailItem.serialize(data+offset, tmpSize, tmpOffset)
|
||||||
&& (offset += tmpOffset);
|
&& (offset += tmpOffset);
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ bool OutgoingRecord::deserialize(
|
|||||||
|
|
||||||
uint8_t tmpStatus = 0;
|
uint8_t tmpStatus = 0;
|
||||||
ok = ok && getRawUInt8(dataPtr, size, &offset, &tmpStatus);
|
ok = ok && getRawUInt8(dataPtr, size, &offset, &tmpStatus);
|
||||||
status = static_cast<GxsMailStatus>(tmpStatus);
|
status = static_cast<GxsTransSendStatus>(tmpStatus);
|
||||||
|
|
||||||
uint32_t tmpSize = size;
|
uint32_t tmpSize = size;
|
||||||
ok = ok && recipient.deserialise(dataPtr, tmpSize, offset);
|
ok = ok && recipient.deserialise(dataPtr, tmpSize, offset);
|
||||||
@ -202,7 +202,7 @@ bool OutgoingRecord::deserialize(
|
|||||||
|
|
||||||
uint16_t cs = 0;
|
uint16_t cs = 0;
|
||||||
ok = ok && getRawUInt16(dataPtr, offset+2, &offset, &cs);
|
ok = ok && getRawUInt16(dataPtr, offset+2, &offset, &cs);
|
||||||
clientService = static_cast<GxsMailSubServices>(cs);
|
clientService = static_cast<GxsTransSubServices>(cs);
|
||||||
|
|
||||||
tmpSize = size;
|
tmpSize = size;
|
||||||
ok = ok && presignedReceipt.deserialize(data, tmpSize, offset);
|
ok = ok && presignedReceipt.deserialize(data, tmpSize, offset);
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "rsgxsitems.h"
|
#include "serialiser/rsgxsitems.h"
|
||||||
#include "serialiser/rsbaseserial.h"
|
#include "serialiser/rsbaseserial.h"
|
||||||
#include "serialiser/rstlvidset.h"
|
#include "serialiser/rstlvidset.h"
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include "services/p3idservice.h"
|
#include "services/p3idservice.h"
|
||||||
|
|
||||||
/// Subservices identifiers (like port for TCP)
|
/// Subservices identifiers (like port for TCP)
|
||||||
enum class GxsMailSubServices : uint16_t
|
enum class GxsTransSubServices : uint16_t
|
||||||
{
|
{
|
||||||
UNKNOWN = 0,
|
UNKNOWN = 0,
|
||||||
TEST_SERVICE = 1,
|
TEST_SERVICE = 1,
|
||||||
@ -36,28 +36,28 @@ enum class GxsMailSubServices : uint16_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Values must fit into uint8_t
|
/// Values must fit into uint8_t
|
||||||
enum class GxsMailItemsSubtypes : uint8_t
|
enum class GxsTransItemsSubtypes : uint8_t
|
||||||
{
|
{
|
||||||
GXS_MAIL_SUBTYPE_MAIL = 1,
|
GXS_TRANS_SUBTYPE_MAIL = 1,
|
||||||
GXS_MAIL_SUBTYPE_RECEIPT = 2,
|
GXS_TRANS_SUBTYPE_RECEIPT = 2,
|
||||||
GXS_MAIL_SUBTYPE_GROUP = 3,
|
GXS_TRANS_SUBTYPE_GROUP = 3,
|
||||||
OUTGOING_RECORD_ITEM = 4
|
OUTGOING_RECORD_ITEM = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint64_t RsGxsMailId;
|
typedef uint64_t RsGxsTransId;
|
||||||
|
|
||||||
struct RsNxsMailPresignedReceipt : RsNxsMsg
|
struct RsNxsTransPresignedReceipt : RsNxsMsg
|
||||||
{
|
{
|
||||||
RsNxsMailPresignedReceipt() : RsNxsMsg(RS_SERVICE_TYPE_GXS_MAIL) {}
|
RsNxsTransPresignedReceipt() : RsNxsMsg(RS_SERVICE_TYPE_GXS_TRANS) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsMailBaseItem : RsGxsMsgItem
|
struct RsGxsTransBaseItem : RsGxsMsgItem
|
||||||
{
|
{
|
||||||
RsGxsMailBaseItem(GxsMailItemsSubtypes subtype) :
|
RsGxsTransBaseItem(GxsTransItemsSubtypes subtype) :
|
||||||
RsGxsMsgItem( RS_SERVICE_TYPE_GXS_MAIL,
|
RsGxsMsgItem( RS_SERVICE_TYPE_GXS_TRANS,
|
||||||
static_cast<uint8_t>(subtype) ), mailId(0) {}
|
static_cast<uint8_t>(subtype) ), mailId(0) {}
|
||||||
|
|
||||||
RsGxsMailId mailId;
|
RsGxsTransId mailId;
|
||||||
|
|
||||||
void inline clear()
|
void inline clear()
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ struct RsGxsMailBaseItem : RsGxsMsgItem
|
|||||||
meta = RsMsgMetaData();
|
meta = RsMsgMetaData();
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t inline size()
|
static uint32_t inline serial_size()
|
||||||
{
|
{
|
||||||
return 8 + // Header
|
return 8 + // Header
|
||||||
8; // mailId
|
8; // mailId
|
||||||
@ -75,29 +75,29 @@ struct RsGxsMailBaseItem : RsGxsMsgItem
|
|||||||
std::ostream &print(std::ostream &out, uint16_t /*indent = 0*/);
|
std::ostream &print(std::ostream &out, uint16_t /*indent = 0*/);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsMailPresignedReceipt : RsGxsMailBaseItem
|
struct RsGxsTransPresignedReceipt : RsGxsTransBaseItem
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt() :
|
RsGxsTransPresignedReceipt() :
|
||||||
RsGxsMailBaseItem(GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT) {}
|
RsGxsTransBaseItem(GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RsGxsMailEncryptionMode : uint8_t
|
enum class RsGxsTransEncryptionMode : uint8_t
|
||||||
{
|
{
|
||||||
CLEAR_TEXT = 1,
|
CLEAR_TEXT = 1,
|
||||||
RSA = 2,
|
RSA = 2,
|
||||||
UNDEFINED_ENCRYPTION = 250
|
UNDEFINED_ENCRYPTION = 250
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsMailItem : RsGxsMailBaseItem
|
struct RsGxsTransMailItem : RsGxsTransBaseItem
|
||||||
{
|
{
|
||||||
RsGxsMailItem() :
|
RsGxsTransMailItem() :
|
||||||
RsGxsMailBaseItem(GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL),
|
RsGxsTransBaseItem(GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL),
|
||||||
cryptoType(RsGxsMailEncryptionMode::UNDEFINED_ENCRYPTION) {}
|
cryptoType(RsGxsTransEncryptionMode::UNDEFINED_ENCRYPTION) {}
|
||||||
|
|
||||||
RsGxsMailEncryptionMode cryptoType;
|
RsGxsTransEncryptionMode cryptoType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief recipientsHint used instead of plain recipient id, so sender can
|
* @brief recipientHint used instead of plain recipient id, so sender can
|
||||||
* decide the equilibrium between exposing the recipient and the cost of
|
* decide the equilibrium between exposing the recipient and the cost of
|
||||||
* completely anonymize it. So a bunch of luky non recipient can conclude
|
* completely anonymize it. So a bunch of luky non recipient can conclude
|
||||||
* rapidly that they are not the recipient without trying to decrypt the
|
* rapidly that they are not the recipient without trying to decrypt the
|
||||||
@ -112,7 +112,7 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
* keys and an arbitrary salt, the more recipients has the mail and the more
|
* keys and an arbitrary salt, the more recipients has the mail and the more
|
||||||
* 1 bits has the salt the less accurate is the hint.
|
* 1 bits has the salt the less accurate is the hint.
|
||||||
* This way the sender is able to adjust the metadata privacy needed for the
|
* This way the sender is able to adjust the metadata privacy needed for the
|
||||||
* message, in the more private case (recipientsHint == 0xFFF...FFF) no one
|
* message, in the more private case (recipientHint == 0xFFF...FFF) no one
|
||||||
* has a clue about who is the actual recipient, while this imply the cost
|
* has a clue about who is the actual recipient, while this imply the cost
|
||||||
* that every potencial recipient has to try to decrypt it to know if it is
|
* that every potencial recipient has to try to decrypt it to know if it is
|
||||||
* for herself. This way a bunch of non recipients can rapidly discover that
|
* for herself. This way a bunch of non recipients can rapidly discover that
|
||||||
@ -149,9 +149,9 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
* is specified */
|
* is specified */
|
||||||
std::vector<uint8_t> payload;
|
std::vector<uint8_t> payload;
|
||||||
|
|
||||||
uint32_t size() const
|
uint32_t serial_size() const
|
||||||
{
|
{
|
||||||
return RsGxsMailBaseItem::size() +
|
return RsGxsTransBaseItem::serial_size() +
|
||||||
1 + // cryptoType
|
1 + // cryptoType
|
||||||
recipientHint.serial_size() +
|
recipientHint.serial_size() +
|
||||||
payload.size();
|
payload.size();
|
||||||
@ -159,7 +159,7 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
bool serialize(uint8_t* data, uint32_t size, uint32_t& offset) const
|
bool serialize(uint8_t* data, uint32_t size, uint32_t& offset) const
|
||||||
{
|
{
|
||||||
bool ok = size < MAX_SIZE;
|
bool ok = size < MAX_SIZE;
|
||||||
ok = ok && RsGxsMailBaseItem::serialize(data, size, offset);
|
ok = ok && RsGxsTransBaseItem::serialize(data, size, offset);
|
||||||
ok = ok && setRawUInt8( data, size, &offset,
|
ok = ok && setRawUInt8( data, size, &offset,
|
||||||
static_cast<uint8_t>(cryptoType) );
|
static_cast<uint8_t>(cryptoType) );
|
||||||
ok = ok && recipientHint.serialise(data, size, offset);
|
ok = ok && recipientHint.serialise(data, size, offset);
|
||||||
@ -175,12 +175,12 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
|
|
||||||
uint32_t roffset = offset;
|
uint32_t roffset = offset;
|
||||||
bool ok = rssize <= size && size < MAX_SIZE;
|
bool ok = rssize <= size && size < MAX_SIZE;
|
||||||
ok = ok && RsGxsMailBaseItem::deserialize(data, rssize, roffset);
|
ok = ok && RsGxsTransBaseItem::deserialize(data, rssize, roffset);
|
||||||
|
|
||||||
void* dataPtr = const_cast<uint8_t*>(data);
|
void* dataPtr = const_cast<uint8_t*>(data);
|
||||||
uint8_t crType;
|
uint8_t crType;
|
||||||
ok = ok && getRawUInt8(dataPtr, rssize, &roffset, &crType);
|
ok = ok && getRawUInt8(dataPtr, rssize, &roffset, &crType);
|
||||||
cryptoType = static_cast<RsGxsMailEncryptionMode>(crType);
|
cryptoType = static_cast<RsGxsTransEncryptionMode>(crType);
|
||||||
ok = ok && recipientHint.deserialise(dataPtr, rssize, roffset);
|
ok = ok && recipientHint.deserialise(dataPtr, rssize, roffset);
|
||||||
uint32_t psz = rssize - roffset;
|
uint32_t psz = rssize - roffset;
|
||||||
ok = ok && (payload.resize(psz), memcpy(&payload[0], data+roffset, psz));
|
ok = ok && (payload.resize(psz), memcpy(&payload[0], data+roffset, psz));
|
||||||
@ -191,8 +191,8 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
}
|
}
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
RsGxsMailBaseItem::clear();
|
RsGxsTransBaseItem::clear();
|
||||||
cryptoType = RsGxsMailEncryptionMode::UNDEFINED_ENCRYPTION;
|
cryptoType = RsGxsTransEncryptionMode::UNDEFINED_ENCRYPTION;
|
||||||
recipientHint.clear();
|
recipientHint.clear();
|
||||||
payload.clear();
|
payload.clear();
|
||||||
}
|
}
|
||||||
@ -201,12 +201,12 @@ struct RsGxsMailItem : RsGxsMailBaseItem
|
|||||||
const static uint32_t MAX_SIZE = 10*8*1024*1024;
|
const static uint32_t MAX_SIZE = 10*8*1024*1024;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsMailGroupItem : RsGxsGrpItem
|
struct RsGxsTransGroupItem : RsGxsGrpItem
|
||||||
{
|
{
|
||||||
RsGxsMailGroupItem() :
|
RsGxsTransGroupItem() :
|
||||||
RsGxsGrpItem( RS_SERVICE_TYPE_GXS_MAIL,
|
RsGxsGrpItem( RS_SERVICE_TYPE_GXS_TRANS,
|
||||||
static_cast<uint8_t>(
|
static_cast<uint8_t>(
|
||||||
GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_GROUP) )
|
GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_GROUP) )
|
||||||
{
|
{
|
||||||
meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||||
meta.mGroupName = "Mail";
|
meta.mGroupName = "Mail";
|
||||||
@ -218,7 +218,7 @@ struct RsGxsMailGroupItem : RsGxsGrpItem
|
|||||||
{ return out; }
|
{ return out; }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GxsMailStatus : uint8_t
|
enum class GxsTransSendStatus : uint8_t
|
||||||
{
|
{
|
||||||
UNKNOWN = 0,
|
UNKNOWN = 0,
|
||||||
PENDING_PROCESSING,
|
PENDING_PROCESSING,
|
||||||
@ -239,19 +239,19 @@ enum class GxsMailStatus : uint8_t
|
|||||||
FAILED_ENCRYPTION
|
FAILED_ENCRYPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGxsMailSerializer;
|
class RsGxsTransSerializer;
|
||||||
struct OutgoingRecord : RsItem
|
struct OutgoingRecord : RsItem
|
||||||
{
|
{
|
||||||
OutgoingRecord( RsGxsId rec, GxsMailSubServices cs,
|
OutgoingRecord( RsGxsId rec, GxsTransSubServices cs,
|
||||||
const uint8_t* data, uint32_t size );
|
const uint8_t* data, uint32_t size );
|
||||||
|
|
||||||
GxsMailStatus status;
|
GxsTransSendStatus status;
|
||||||
RsGxsId recipient;
|
RsGxsId recipient;
|
||||||
/// Don't use a pointer would be invalid after publish
|
/// Don't use a pointer would be invalid after publish
|
||||||
RsGxsMailItem mailItem;
|
RsGxsTransMailItem mailItem;
|
||||||
std::vector<uint8_t> mailData;
|
std::vector<uint8_t> mailData;
|
||||||
GxsMailSubServices clientService;
|
GxsTransSubServices clientService;
|
||||||
RsNxsMailPresignedReceipt presignedReceipt;
|
RsNxsTransPresignedReceipt presignedReceipt;
|
||||||
|
|
||||||
uint32_t size() const;
|
uint32_t size() const;
|
||||||
bool serialize(uint8_t* data, uint32_t size, uint32_t& offset) const;
|
bool serialize(uint8_t* data, uint32_t size, uint32_t& offset) const;
|
||||||
@ -261,32 +261,32 @@ struct OutgoingRecord : RsItem
|
|||||||
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RsGxsMailSerializer;
|
friend class RsGxsTransSerializer;
|
||||||
OutgoingRecord();
|
OutgoingRecord();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RsGxsMailSerializer : RsSerialType
|
struct RsGxsTransSerializer : RsSerialType
|
||||||
{
|
{
|
||||||
RsGxsMailSerializer() : RsSerialType( RS_PKT_VERSION_SERVICE,
|
RsGxsTransSerializer() : RsSerialType( RS_PKT_VERSION_SERVICE,
|
||||||
RS_SERVICE_TYPE_GXS_MAIL ) {}
|
RS_SERVICE_TYPE_GXS_TRANS ) {}
|
||||||
~RsGxsMailSerializer() {}
|
~RsGxsTransSerializer() {}
|
||||||
|
|
||||||
uint32_t size(RsItem* item)
|
uint32_t size(RsItem* item)
|
||||||
{
|
{
|
||||||
uint32_t sz = 0;
|
uint32_t sz = 0;
|
||||||
switch(static_cast<GxsMailItemsSubtypes>(item->PacketSubType()))
|
switch(static_cast<GxsTransItemsSubtypes>(item->PacketSubType()))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
{
|
{
|
||||||
RsGxsMailItem* i = dynamic_cast<RsGxsMailItem*>(item);
|
RsGxsTransMailItem* i = dynamic_cast<RsGxsTransMailItem*>(item);
|
||||||
if(i) sz = i->size();
|
if(i) sz = i->serial_size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
sz = RsGxsMailPresignedReceipt::size(); break;
|
sz = RsGxsTransPresignedReceipt::serial_size(); break;
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_GROUP: sz = 8; break;
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_GROUP: sz = 8; break;
|
||||||
case GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM:
|
case GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM:
|
||||||
{
|
{
|
||||||
OutgoingRecord* ci = dynamic_cast<OutgoingRecord*>(item);
|
OutgoingRecord* ci = dynamic_cast<OutgoingRecord*>(item);
|
||||||
if(ci) sz = ci->size();
|
if(ci) sz = ci->size();
|
||||||
@ -309,7 +309,7 @@ struct RsGxsMailSerializer : RsSerialType
|
|||||||
const uint8_t* dataPtr = reinterpret_cast<uint8_t*>(data);
|
const uint8_t* dataPtr = reinterpret_cast<uint8_t*>(data);
|
||||||
|
|
||||||
if ( (RS_PKT_VERSION_SERVICE != pktv) || // 0x02
|
if ( (RS_PKT_VERSION_SERVICE != pktv) || // 0x02
|
||||||
(RS_SERVICE_TYPE_GXS_MAIL != srvc) || // 0x0230 = 560
|
(RS_SERVICE_TYPE_GXS_TRANS != srvc) || // 0x0230 = 560
|
||||||
(*size < rssize) )
|
(*size < rssize) )
|
||||||
{
|
{
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
@ -320,30 +320,30 @@ struct RsGxsMailSerializer : RsSerialType
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
RsItem* ret = NULL;
|
RsItem* ret = NULL;
|
||||||
|
|
||||||
switch (static_cast<GxsMailItemsSubtypes>(getRsItemSubType(rstype)))
|
switch (static_cast<GxsTransItemsSubtypes>(getRsItemSubType(rstype)))
|
||||||
{
|
{
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_MAIL:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL:
|
||||||
{
|
{
|
||||||
RsGxsMailItem* i = new RsGxsMailItem();
|
RsGxsTransMailItem* i = new RsGxsTransMailItem();
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
ok = ok && i->deserialize(dataPtr, *size, offset);
|
ok = ok && i->deserialize(dataPtr, *size, offset);
|
||||||
ret = i;
|
ret = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_RECEIPT:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT:
|
||||||
{
|
{
|
||||||
RsGxsMailPresignedReceipt* i = new RsGxsMailPresignedReceipt();
|
RsGxsTransPresignedReceipt* i = new RsGxsTransPresignedReceipt();
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
ok &= i->deserialize(dataPtr, *size, offset);
|
ok &= i->deserialize(dataPtr, *size, offset);
|
||||||
ret = i;
|
ret = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::GXS_MAIL_SUBTYPE_GROUP:
|
case GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_GROUP:
|
||||||
{
|
{
|
||||||
ret = new RsGxsMailGroupItem();
|
ret = new RsGxsTransGroupItem();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailItemsSubtypes::OUTGOING_RECORD_ITEM:
|
case GxsTransItemsSubtypes::OUTGOING_RECORD_ITEM:
|
||||||
{
|
{
|
||||||
OutgoingRecord* i = new OutgoingRecord();
|
OutgoingRecord* i = new OutgoingRecord();
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
@ -852,9 +852,9 @@ gxsphotoshare {
|
|||||||
serialiser/rsphotoitems.cc \
|
serialiser/rsphotoitems.cc \
|
||||||
}
|
}
|
||||||
|
|
||||||
rs_gxs_mail {
|
rs_gxs_trans {
|
||||||
HEADERS += serialiser/rsgxsmailitems.h services/p3gxsmails.h
|
HEADERS += gxstrans/p3gxstransitems.h gxstrans/p3gxstrans.h
|
||||||
SOURCES += serialiser/rsgxsmailitems.cc services/p3gxsmails.cpp
|
SOURCES += gxstrans/p3gxstransitems.cc gxstrans/p3gxstrans.cc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ RsServer::RsServer()
|
|||||||
|
|
||||||
RsServer::~RsServer()
|
RsServer::~RsServer()
|
||||||
{
|
{
|
||||||
delete mGxsMails;
|
delete mGxsTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General Internal Helper Functions
|
/* General Internal Helper Functions
|
||||||
|
@ -179,7 +179,7 @@ class RsServer: public RsControl, public RsTickingThread
|
|||||||
// p3GxsForums *mGxsForums;
|
// p3GxsForums *mGxsForums;
|
||||||
// p3GxsChannels *mGxsChannels;
|
// p3GxsChannels *mGxsChannels;
|
||||||
// p3Wire *mWire;
|
// p3Wire *mWire;
|
||||||
p3GxsMails* mGxsMails;
|
p3GxsTrans* mGxsTrans;
|
||||||
|
|
||||||
/* Config */
|
/* Config */
|
||||||
p3ConfigMgr *mConfigMgr;
|
p3ConfigMgr *mConfigMgr;
|
||||||
|
@ -82,8 +82,8 @@
|
|||||||
#include "tcponudp/udpstunner.h"
|
#include "tcponudp/udpstunner.h"
|
||||||
#endif // RS_USE_DHT_STUNNER
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
#ifdef RS_GXS_MAIL
|
#ifdef RS_GXS_TRANS
|
||||||
# include "services/p3gxsmails.h"
|
# include "gxstrans/p3gxstrans.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define GPG_DEBUG
|
// #define GPG_DEBUG
|
||||||
@ -1484,22 +1484,18 @@ int RsServer::StartupRetroShare()
|
|||||||
pqih->addService(gxschannels_ns, true);
|
pqih->addService(gxschannels_ns, true);
|
||||||
//pqih->addService(photo_ns, true);
|
//pqih->addService(photo_ns, true);
|
||||||
|
|
||||||
# ifdef RS_GXS_MAIL
|
# ifdef RS_GXS_TRANS
|
||||||
RsGeneralDataService* gxsmail_ds = new RsDataService(
|
RsGeneralDataService* gxstrans_ds = new RsDataService(
|
||||||
currGxsDir + "/", "gxsmails_db", RS_SERVICE_TYPE_GXS_MAIL,
|
currGxsDir + "/", "gxstrans_db", RS_SERVICE_TYPE_GXS_TRANS,
|
||||||
NULL, rsInitConfig->gxs_passwd );
|
NULL, rsInitConfig->gxs_passwd );
|
||||||
mGxsMails = new p3GxsMails(gxsmail_ds, NULL, *mGxsIdService);
|
mGxsTrans = new p3GxsTrans(gxstrans_ds, NULL, *mGxsIdService);
|
||||||
RsGxsNetService* gxsmails_ns = new RsGxsNetService(
|
RsGxsNetService* gxstrans_ns = new RsGxsNetService(
|
||||||
RS_SERVICE_TYPE_GXS_MAIL, gxsmail_ds, nxsMgr, mGxsMails,
|
RS_SERVICE_TYPE_GXS_TRANS, gxstrans_ds, nxsMgr, mGxsTrans,
|
||||||
mGxsMails->getServiceInfo(), mReputations, mGxsCircles,
|
mGxsTrans->getServiceInfo(), mReputations, mGxsCircles,
|
||||||
mGxsIdService, pgpAuxUtils);
|
mGxsIdService, pgpAuxUtils);
|
||||||
mGxsMails->setNetworkExchangeService(gxsmails_ns);
|
mGxsTrans->setNetworkExchangeService(gxstrans_ns);
|
||||||
pqih->addService(gxsmails_ns, true);
|
pqih->addService(gxstrans_ns, true);
|
||||||
# ifdef TEST_RS_GXS_MAIL
|
# endif // RS_GXS_TRANS
|
||||||
TestGxsMailClientService* tgms =
|
|
||||||
new TestGxsMailClientService(*mGxsMails, *mGxsIdService);
|
|
||||||
# endif // TEST_RS_GXS_MAIL
|
|
||||||
# endif // RS_GXS_MAIL
|
|
||||||
|
|
||||||
// remove pword from memory
|
// remove pword from memory
|
||||||
rsInitConfig->gxs_passwd = "";
|
rsInitConfig->gxs_passwd = "";
|
||||||
@ -1510,9 +1506,9 @@ int RsServer::StartupRetroShare()
|
|||||||
p3ServiceInfo *serviceInfo = new p3ServiceInfo(serviceCtrl);
|
p3ServiceInfo *serviceInfo = new p3ServiceInfo(serviceCtrl);
|
||||||
mDisc = new p3discovery2(mPeerMgr, mLinkMgr, mNetMgr, serviceCtrl);
|
mDisc = new p3discovery2(mPeerMgr, mLinkMgr, mNetMgr, serviceCtrl);
|
||||||
mHeart = new p3heartbeat(serviceCtrl, pqih);
|
mHeart = new p3heartbeat(serviceCtrl, pqih);
|
||||||
msgSrv = new p3MsgService( serviceCtrl, mGxsIdService, *mGxsMails );
|
msgSrv = new p3MsgService( serviceCtrl, mGxsIdService, *mGxsTrans );
|
||||||
chatSrv = new p3ChatService( serviceCtrl,mGxsIdService, mLinkMgr,
|
chatSrv = new p3ChatService( serviceCtrl,mGxsIdService, mLinkMgr,
|
||||||
mHistoryMgr, *mGxsMails );
|
mHistoryMgr, *mGxsTrans );
|
||||||
mStatusSrv = new p3StatusService(serviceCtrl);
|
mStatusSrv = new p3StatusService(serviceCtrl);
|
||||||
|
|
||||||
#ifdef ENABLE_GROUTER
|
#ifdef ENABLE_GROUTER
|
||||||
@ -1678,10 +1674,10 @@ int RsServer::StartupRetroShare()
|
|||||||
|
|
||||||
#ifdef RS_ENABLE_GXS
|
#ifdef RS_ENABLE_GXS
|
||||||
|
|
||||||
# ifdef RS_GXS_MAIL
|
# ifdef RS_GXS_TRANS
|
||||||
mConfigMgr->addConfiguration("gxs_mail_ns.cfg", gxsmails_ns);
|
mConfigMgr->addConfiguration("gxs_trans_ns.cfg", gxstrans_ns);
|
||||||
mConfigMgr->addConfiguration("gxs_mail.cfg", mGxsMails);
|
mConfigMgr->addConfiguration("gxs_trans.cfg", mGxsTrans);
|
||||||
# endif
|
# endif // RS_GXS_TRANS
|
||||||
|
|
||||||
mConfigMgr->addConfiguration("p3identity.cfg", mGxsIdService);
|
mConfigMgr->addConfiguration("p3identity.cfg", mGxsIdService);
|
||||||
|
|
||||||
@ -1830,13 +1826,10 @@ int RsServer::StartupRetroShare()
|
|||||||
//createThread(*photo_ns);
|
//createThread(*photo_ns);
|
||||||
//createThread(*wire_ns);
|
//createThread(*wire_ns);
|
||||||
|
|
||||||
# ifdef RS_GXS_MAIL
|
# ifdef RS_GXS_TRANS
|
||||||
startServiceThread(mGxsMails, "gxs mail");
|
startServiceThread(mGxsTrans, "gxs trans");
|
||||||
startServiceThread(gxsmails_ns, "gxs mail ns");
|
startServiceThread(gxstrans_ns, "gxs trans ns");
|
||||||
# ifdef TEST_RS_GXS_MAIL
|
# endif // RS_GXS_TRANS
|
||||||
tgms->start("Gxs Mail Test Service");
|
|
||||||
# endif // TEST_RS_GXS_MAIL
|
|
||||||
# endif // RS_GXS_MAIL
|
|
||||||
|
|
||||||
#endif // RS_ENABLE_GXS
|
#endif // RS_ENABLE_GXS
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ const uint16_t RS_SERVICE_GXS_TYPE_GXSCIRCLE = 0x0218;
|
|||||||
// not gxs, but used with identities.
|
// not gxs, but used with identities.
|
||||||
const uint16_t RS_SERVICE_GXS_TYPE_REPUTATION = 0x0219;
|
const uint16_t RS_SERVICE_GXS_TYPE_REPUTATION = 0x0219;
|
||||||
const uint16_t RS_SERVICE_TYPE_GXS_RECOGN = 0x0220;
|
const uint16_t RS_SERVICE_TYPE_GXS_RECOGN = 0x0220;
|
||||||
const uint16_t RS_SERVICE_TYPE_GXS_MAIL = 0x0230;
|
const uint16_t RS_SERVICE_TYPE_GXS_TRANS = 0x0230;
|
||||||
|
|
||||||
// Experimental Services.
|
// Experimental Services.
|
||||||
/* DSDV Testing at the moment - Service Only */
|
/* DSDV Testing at the moment - Service Only */
|
||||||
|
@ -86,12 +86,12 @@ static const uint32_t RS_MSG_DISTANT_MESSAGE_HASH_KEEP_TIME = 2*30*86400 ; // ke
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
p3MsgService::p3MsgService( p3ServiceControl *sc, p3IdService *id_serv,
|
p3MsgService::p3MsgService( p3ServiceControl *sc, p3IdService *id_serv,
|
||||||
p3GxsMails& gxsMS )
|
p3GxsTrans& gxsMS )
|
||||||
: p3Service(), p3Config(),
|
: p3Service(), p3Config(),
|
||||||
gxsOngoingMutex("p3MsgService Gxs Outgoing Mutex"), mIdService(id_serv),
|
gxsOngoingMutex("p3MsgService Gxs Outgoing Mutex"), mIdService(id_serv),
|
||||||
mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(0),
|
mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(0),
|
||||||
recentlyReceivedMutex("p3MsgService recently received hash mutex"),
|
recentlyReceivedMutex("p3MsgService recently received hash mutex"),
|
||||||
gxsMailService(gxsMS)
|
mGxsTransServ(gxsMS)
|
||||||
{
|
{
|
||||||
/* this serialiser is used for services. It's not the same than the one
|
/* this serialiser is used for services. It's not the same than the one
|
||||||
* returned by setupSerialiser(). We need both!! */
|
* returned by setupSerialiser(). We need both!! */
|
||||||
@ -108,7 +108,7 @@ p3MsgService::p3MsgService( p3ServiceControl *sc, p3IdService *id_serv,
|
|||||||
|
|
||||||
if(sc) initStandardTagTypes(); // Initialize standard tag types
|
if(sc) initStandardTagTypes(); // Initialize standard tag types
|
||||||
|
|
||||||
gxsMailService.registerGxsMailsClient( GxsMailSubServices::P3_MSG_SERVICE,
|
mGxsTransServ.registerGxsTransClient( GxsTransSubServices::P3_MSG_SERVICE,
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1990,12 +1990,12 @@ uint32_t p3MsgService::getDistantMessagingPermissionFlags()
|
|||||||
return mDistantMessagePermissions ;
|
return mDistantMessagePermissions ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::receiveGxsMail( const RsGxsId& authorId,
|
bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& recipientId,
|
const RsGxsId& recipientId,
|
||||||
const uint8_t* data, uint32_t dataSize )
|
const uint8_t* data, uint32_t dataSize )
|
||||||
{
|
{
|
||||||
std::cout << "p3MsgService::receiveGxsMail(" << authorId
|
std::cout << __PRETTY_FUNCTION__ << " " << authorId << ", " << recipientId
|
||||||
<< ", " << recipientId << ", " << dataSize << ")" << std::endl;
|
<< ",, " << dataSize << std::endl;
|
||||||
|
|
||||||
Sha1CheckSum hash = RsDirUtil::sha1sum(data, dataSize);
|
Sha1CheckSum hash = RsDirUtil::sha1sum(data, dataSize);
|
||||||
|
|
||||||
@ -2004,7 +2004,7 @@ bool p3MsgService::receiveGxsMail( const RsGxsId& authorId,
|
|||||||
if( mRecentlyReceivedMessageHashes.find(hash) !=
|
if( mRecentlyReceivedMessageHashes.find(hash) !=
|
||||||
mRecentlyReceivedMessageHashes.end() )
|
mRecentlyReceivedMessageHashes.end() )
|
||||||
{
|
{
|
||||||
std::cerr << "p3MsgService::receiveGxsMail(...) (II) receiving "
|
std::cerr << __PRETTY_FUNCTION__ << " (II) receiving "
|
||||||
<< "message of hash " << hash << " more than once. "
|
<< "message of hash " << hash << " more than once. "
|
||||||
<< "Probably it has arrived before by other means."
|
<< "Probably it has arrived before by other means."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -2020,8 +2020,8 @@ bool p3MsgService::receiveGxsMail( const RsGxsId& authorId,
|
|||||||
|
|
||||||
if(msg_item)
|
if(msg_item)
|
||||||
{
|
{
|
||||||
std::cerr << "p3MsgService::receiveGxsMail(...) Encrypted item "
|
std::cerr << __PRETTY_FUNCTION__ << " Encrypted item correctly "
|
||||||
<< "correctly deserialised. Passing on to incoming list."
|
<< "deserialised. Passing on to incoming list."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
msg_item->msgFlags |= RS_MSG_FLAGS_DISTANT;
|
msg_item->msgFlags |= RS_MSG_FLAGS_DISTANT;
|
||||||
@ -2035,7 +2035,7 @@ bool p3MsgService::receiveGxsMail( const RsGxsId& authorId,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "p3MsgService::receiveGxsMail(...) Item could not be "
|
std::cerr << __PRETTY_FUNCTION__ << " Item could not be "
|
||||||
<< "deserialised. Format error??" << std::endl;
|
<< "deserialised. Format error??" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2043,26 +2043,26 @@ bool p3MsgService::receiveGxsMail( const RsGxsId& authorId,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||||
GxsMailStatus status )
|
GxsTransSendStatus status )
|
||||||
{
|
{
|
||||||
std::cout << "p3MsgService::notifySendMailStatus(" << originalMessage.mailId
|
std::cout << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
||||||
<< ", " << static_cast<uint>(status) << ")" << std::endl;
|
<< static_cast<uint>(status) << std::endl;
|
||||||
|
|
||||||
if( status == GxsMailStatus::RECEIPT_RECEIVED )
|
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||||
{
|
{
|
||||||
uint32_t msg_id;
|
uint32_t msg_id;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(gxsOngoingMutex);
|
RS_STACK_MUTEX(gxsOngoingMutex);
|
||||||
|
|
||||||
auto it = gxsOngoingMessages.find(originalMessage.mailId);
|
auto it = gxsOngoingMessages.find(mailId);
|
||||||
if(it == gxsOngoingMessages.end())
|
if(it == gxsOngoingMessages.end())
|
||||||
{
|
{
|
||||||
std::cerr << "p3MsgService::notifySendMailStatus("
|
std::cerr << __PRETTY_FUNCTION__<< " "
|
||||||
<< originalMessage.mailId
|
<< mailId
|
||||||
<< ", " << static_cast<uint>(status) << ") "
|
<< ", " << static_cast<uint>(status)
|
||||||
<< "(EE) cannot find pending message to acknowledge!"
|
<< " (EE) cannot find pending message to acknowledge!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2078,9 +2078,8 @@ bool p3MsgService::notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
|||||||
auto it2 = msgOutgoing.find(msg_id);
|
auto it2 = msgOutgoing.find(msg_id);
|
||||||
if(it2 == msgOutgoing.end())
|
if(it2 == msgOutgoing.end())
|
||||||
{
|
{
|
||||||
std::cerr << "p3MsgService::notifySendMailStatus("
|
std::cerr << __PRETTY_FUNCTION__ << " " << mailId
|
||||||
<< originalMessage.mailId
|
<< ", " << static_cast<uint>(status) << " (II) "
|
||||||
<< ", " << static_cast<uint>(status) << ") (II) "
|
|
||||||
<< "received receipt for message that is not in "
|
<< "received receipt for message that is not in "
|
||||||
<< "outgoing list, probably it has been acknoweldged "
|
<< "outgoing list, probably it has been acknoweldged "
|
||||||
<< "before by other means." << std::endl;
|
<< "before by other means." << std::endl;
|
||||||
@ -2098,18 +2097,18 @@ bool p3MsgService::notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( status >= GxsMailStatus::FAILED_RECEIPT_SIGNATURE )
|
if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||||
{
|
{
|
||||||
uint32_t msg_id;
|
uint32_t msg_id;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(gxsOngoingMutex);
|
RS_STACK_MUTEX(gxsOngoingMutex);
|
||||||
|
|
||||||
std::cerr << "p3MsgService::notifySendMailStatus(...) mail delivery"
|
std::cerr << __PRETTY_FUNCTION__ << " mail delivery "
|
||||||
<< "mailId: " << originalMessage.mailId
|
<< "mailId: " << mailId
|
||||||
<< " failed with " << static_cast<uint32_t>(status);
|
<< " failed with " << static_cast<uint32_t>(status);
|
||||||
|
|
||||||
auto it = gxsOngoingMessages.find(originalMessage.mailId);
|
auto it = gxsOngoingMessages.find(mailId);
|
||||||
if(it == gxsOngoingMessages.end())
|
if(it == gxsOngoingMessages.end())
|
||||||
{
|
{
|
||||||
std::cerr << " cannot find pending message to notify"
|
std::cerr << " cannot find pending message to notify"
|
||||||
@ -2258,8 +2257,8 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
|
|||||||
mGRouter->sendData( destination_key_id, GROUTER_CLIENT_ID_MESSAGES,
|
mGRouter->sendData( destination_key_id, GROUTER_CLIENT_ID_MESSAGES,
|
||||||
msg_serialized_data, msg_serialized_rssize,
|
msg_serialized_data, msg_serialized_rssize,
|
||||||
signing_key_id, grouter_message_id );
|
signing_key_id, grouter_message_id );
|
||||||
RsGxsMailId gxsMailId;
|
RsGxsTransId gxsMailId;
|
||||||
gxsMailService.sendMail( gxsMailId, GxsMailSubServices::P3_MSG_SERVICE,
|
mGxsTransServ.sendMail( gxsMailId, GxsTransSubServices::P3_MSG_SERVICE,
|
||||||
signing_key_id, destination_key_id,
|
signing_key_id, destination_key_id,
|
||||||
msg_serialized_data, msg_serialized_rssize );
|
msg_serialized_data, msg_serialized_rssize );
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#include "grouter/grouterclientservice.h"
|
#include "grouter/grouterclientservice.h"
|
||||||
#include "turtle/p3turtle.h"
|
#include "turtle/p3turtle.h"
|
||||||
#include "turtle/turtleclientservice.h"
|
#include "turtle/turtleclientservice.h"
|
||||||
#include "services/p3gxsmails.h"
|
#include "gxstrans/p3gxstrans.h"
|
||||||
|
|
||||||
class p3LinkMgr;
|
class p3LinkMgr;
|
||||||
class p3IdService;
|
class p3IdService;
|
||||||
@ -57,9 +57,9 @@ class p3IdService;
|
|||||||
// Temp tweak to test grouter
|
// Temp tweak to test grouter
|
||||||
struct p3MsgService :
|
struct p3MsgService :
|
||||||
p3Service, p3Config, pqiServiceMonitor, GRouterClientService,
|
p3Service, p3Config, pqiServiceMonitor, GRouterClientService,
|
||||||
GxsMailsClient
|
GxsTransClient
|
||||||
{
|
{
|
||||||
p3MsgService(p3ServiceControl *sc, p3IdService *id_service, p3GxsMails& gxsMS);
|
p3MsgService(p3ServiceControl *sc, p3IdService *id_service, p3GxsTrans& gxsMS);
|
||||||
|
|
||||||
virtual RsServiceInfo getServiceInfo();
|
virtual RsServiceInfo getServiceInfo();
|
||||||
|
|
||||||
@ -135,14 +135,14 @@ struct p3MsgService :
|
|||||||
void setDistantMessagingPermissionFlags(uint32_t flags) ;
|
void setDistantMessagingPermissionFlags(uint32_t flags) ;
|
||||||
uint32_t getDistantMessagingPermissionFlags() ;
|
uint32_t getDistantMessagingPermissionFlags() ;
|
||||||
|
|
||||||
/// @see GxsMailsClient::receiveGxsMail(...)
|
/// @see GxsTransClient::receiveGxsTransMail(...)
|
||||||
virtual bool receiveGxsMail( const RsGxsId& authorId,
|
virtual bool receiveGxsTransMail( const RsGxsId& authorId,
|
||||||
const RsGxsId& recipientId,
|
const RsGxsId& recipientId,
|
||||||
const uint8_t* data, uint32_t dataSize );
|
const uint8_t* data, uint32_t dataSize );
|
||||||
|
|
||||||
/// @see GxsMailsClient::notifySendMailStatus(...)
|
/// @see GxsTransClient::notifyGxsTransSendStatus(...)
|
||||||
virtual bool notifySendMailStatus( const RsGxsMailItem& originalMessage,
|
virtual bool notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||||
GxsMailStatus status );
|
GxsTransSendStatus status );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendDistantMsgItem(RsMsgItem *msgitem);
|
void sendDistantMsgItem(RsMsgItem *msgitem);
|
||||||
@ -152,7 +152,7 @@ private:
|
|||||||
std::map<GRouterMsgPropagationId, uint32_t> _ongoing_messages;
|
std::map<GRouterMsgPropagationId, uint32_t> _ongoing_messages;
|
||||||
|
|
||||||
/// Contains ongoing messages handed to gxs mail
|
/// Contains ongoing messages handed to gxs mail
|
||||||
std::map<RsGxsMailId, uint32_t> gxsOngoingMessages;
|
std::map<RsGxsTransId, uint32_t> gxsOngoingMessages;
|
||||||
RsMutex gxsOngoingMutex;
|
RsMutex gxsOngoingMutex;
|
||||||
|
|
||||||
// Overloaded from GRouterClientService
|
// Overloaded from GRouterClientService
|
||||||
@ -229,7 +229,7 @@ private:
|
|||||||
uint32_t mDistantMessagePermissions ;
|
uint32_t mDistantMessagePermissions ;
|
||||||
bool mShouldEnableDistantMessaging ;
|
bool mShouldEnableDistantMessaging ;
|
||||||
|
|
||||||
p3GxsMails& gxsMailService;
|
p3GxsTrans& mGxsTransServ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_SERVICE_HEADER
|
#endif // MESSAGE_SERVICE_HEADER
|
||||||
|
@ -61,9 +61,9 @@ CONFIG *= no_rs_nocppwarning
|
|||||||
rs_nocppwarning:CONFIG -= no_rs_nocppwarning
|
rs_nocppwarning:CONFIG -= no_rs_nocppwarning
|
||||||
|
|
||||||
# To disable GXS mail append the following assignation to qmake command line
|
# To disable GXS mail append the following assignation to qmake command line
|
||||||
# "CONFIG+=no_rs_gxs_mail"
|
# "CONFIG+=no_rs_gxs_trans"
|
||||||
CONFIG *= rs_gxs_mail
|
CONFIG *= rs_gxs_trans
|
||||||
#no_rs_gxs_mail:CONFIG -= rs_gxs_mail ## Disabing not supported ATM
|
#no_rs_gxs_trans:CONFIG -= rs_gxs_trans ## Disabing not supported ATM
|
||||||
|
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
@ -173,17 +173,17 @@ rs_nodeprecatedwarning {
|
|||||||
QMAKE_CXXFLAGS += -Wno-deprecated
|
QMAKE_CXXFLAGS += -Wno-deprecated
|
||||||
QMAKE_CXXFLAGS += -Wno-deprecated-declarations
|
QMAKE_CXXFLAGS += -Wno-deprecated-declarations
|
||||||
DEFINES *= RS_NO_WARN_DEPRECATED
|
DEFINES *= RS_NO_WARN_DEPRECATED
|
||||||
warning("QMAKE: You have disable deprecated warnings.")
|
warning("QMAKE: You have disabled deprecated warnings.")
|
||||||
}
|
}
|
||||||
|
|
||||||
rs_nocppwarning {
|
rs_nocppwarning {
|
||||||
QMAKE_CXXFLAGS += -Wno-cpp
|
QMAKE_CXXFLAGS += -Wno-cpp
|
||||||
DEFINES *= RS_NO_WARN_CPP
|
DEFINES *= RS_NO_WARN_CPP
|
||||||
warning("QMAKE: You have disable C preprocessor warnings.")
|
warning("QMAKE: You have disabled C preprocessor warnings.")
|
||||||
}
|
}
|
||||||
|
|
||||||
rs_gxs_mail {
|
rs_gxs_trans {
|
||||||
DEFINES *= RS_GXS_MAIL
|
DEFINES *= RS_GXS_TRANS
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user