mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
minor code cleaning in p3GxsTrans (struct->class for consistency, sendMail->sendData), added popularity+subscribed status display in statistics
This commit is contained in:
parent
6da8b2a04d
commit
eea63ac217
8 changed files with 103 additions and 111 deletions
|
@ -349,7 +349,7 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||
uint32_t sz = _serializer->size(ci);
|
||||
std::vector<uint8_t> data; data.resize(sz);
|
||||
_serializer->serialise(ci, &data[0], &sz);
|
||||
mGxsTransport.sendMail(tId, GxsTransSubServices::P3_CHAT_SERVICE,
|
||||
mGxsTransport.sendData(tId, GxsTransSubServices::P3_CHAT_SERVICE,
|
||||
de.from, de.to, &data[0], sz);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -63,7 +63,7 @@ bool p3GxsTrans::getStatistics(GxsTransStatistics& stats)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsTrans::sendMail( RsGxsTransId& mailId,
|
||||
bool p3GxsTrans::sendData( RsGxsTransId& mailId,
|
||||
GxsTransSubServices service,
|
||||
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
||||
const uint8_t* data, uint32_t size,
|
||||
|
@ -558,6 +558,7 @@ void p3GxsTrans::processOutgoingRecord(OutgoingRecord& pr)
|
|||
{
|
||||
pr.mailItem.saltRecipientHint(pr.recipient);
|
||||
pr.mailItem.saltRecipientHint(RsGxsId::random());
|
||||
pr.mailItem.meta.mPublishTs = time(NULL);
|
||||
}
|
||||
case GxsTransSendStatus::PENDING_PREFERRED_GROUP:
|
||||
{
|
||||
|
@ -640,8 +641,7 @@ void p3GxsTrans::processOutgoingRecord(OutgoingRecord& pr)
|
|||
pr.recipient, encryptError, true ) )
|
||||
{
|
||||
pr.mailItem.payload.resize(encryptedSize);
|
||||
memcpy( &pr.mailItem.payload[0], encryptedData,
|
||||
encryptedSize );
|
||||
memcpy( &pr.mailItem.payload[0], encryptedData, encryptedSize );
|
||||
free(encryptedData);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
* This method is part of the public interface of this service.
|
||||
* @return true if the mail will be sent, false if not
|
||||
*/
|
||||
bool sendMail( RsGxsTransId& mailId,
|
||||
bool sendData( RsGxsTransId& mailId,
|
||||
GxsTransSubServices service,
|
||||
const RsGxsId& own_gxsid, const RsGxsId& recipient,
|
||||
const uint8_t* data, uint32_t size,
|
||||
|
|
|
@ -28,17 +28,23 @@
|
|||
#include "services/p3idservice.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
|
||||
struct RsNxsTransPresignedReceipt : RsNxsMsg
|
||||
class RsNxsTransPresignedReceipt : public RsNxsMsg
|
||||
{
|
||||
public:
|
||||
RsNxsTransPresignedReceipt() : RsNxsMsg(RS_SERVICE_TYPE_GXS_TRANS) {}
|
||||
|
||||
virtual ~RsNxsTransPresignedReceipt() {}
|
||||
};
|
||||
|
||||
struct RsGxsTransBaseItem : RsGxsMsgItem
|
||||
class RsGxsTransBaseItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
RsGxsTransBaseItem(GxsTransItemsSubtypes subtype) :
|
||||
RsGxsMsgItem( RS_SERVICE_TYPE_GXS_TRANS,
|
||||
static_cast<uint8_t>(subtype) ), mailId(0) {}
|
||||
|
||||
virtual ~RsGxsTransBaseItem() {}
|
||||
|
||||
RsGxsTransId mailId;
|
||||
|
||||
void inline clear()
|
||||
|
@ -52,10 +58,11 @@ struct RsGxsTransBaseItem : RsGxsMsgItem
|
|||
{ RS_REGISTER_SERIAL_MEMBER_TYPED(mailId, uint64_t); }
|
||||
};
|
||||
|
||||
struct RsGxsTransPresignedReceipt : RsGxsTransBaseItem
|
||||
class RsGxsTransPresignedReceipt : public RsGxsTransBaseItem
|
||||
{
|
||||
RsGxsTransPresignedReceipt() :
|
||||
RsGxsTransBaseItem(GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT) {}
|
||||
public:
|
||||
RsGxsTransPresignedReceipt() : RsGxsTransBaseItem(GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_RECEIPT) {}
|
||||
virtual ~RsGxsTransPresignedReceipt() {}
|
||||
};
|
||||
|
||||
enum class RsGxsTransEncryptionMode : uint8_t
|
||||
|
@ -65,12 +72,15 @@ enum class RsGxsTransEncryptionMode : uint8_t
|
|||
UNDEFINED_ENCRYPTION = 250
|
||||
};
|
||||
|
||||
struct RsGxsTransMailItem : RsGxsTransBaseItem
|
||||
class RsGxsTransMailItem : public RsGxsTransBaseItem
|
||||
{
|
||||
public:
|
||||
RsGxsTransMailItem() :
|
||||
RsGxsTransBaseItem(GxsTransItemsSubtypes::GXS_TRANS_SUBTYPE_MAIL),
|
||||
cryptoType(RsGxsTransEncryptionMode::UNDEFINED_ENCRYPTION) {}
|
||||
|
||||
virtual ~RsGxsTransMailItem() {}
|
||||
|
||||
RsGxsTransEncryptionMode cryptoType;
|
||||
|
||||
/**
|
||||
|
@ -147,8 +157,9 @@ struct RsGxsTransMailItem : RsGxsTransBaseItem
|
|||
const static uint32_t MAX_SIZE = 10*8*1024*1024;
|
||||
};
|
||||
|
||||
struct RsGxsTransGroupItem : RsGxsGrpItem
|
||||
class RsGxsTransGroupItem : public RsGxsGrpItem
|
||||
{
|
||||
public:
|
||||
RsGxsTransGroupItem() :
|
||||
RsGxsGrpItem( RS_SERVICE_TYPE_GXS_TRANS,
|
||||
static_cast<uint8_t>(
|
||||
|
@ -158,6 +169,7 @@ struct RsGxsTransGroupItem : RsGxsGrpItem
|
|||
meta.mGroupName = "Mail";
|
||||
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
|
||||
}
|
||||
virtual ~RsGxsTransGroupItem() {}
|
||||
|
||||
// TODO: Talk with Cyril why there is no RsGxsGrpItem::serial_process
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob /*j*/,
|
||||
|
@ -170,11 +182,15 @@ struct RsGxsTransGroupItem : RsGxsGrpItem
|
|||
};
|
||||
|
||||
class RsGxsTransSerializer;
|
||||
struct OutgoingRecord : RsItem
|
||||
|
||||
class OutgoingRecord : public RsItem
|
||||
{
|
||||
public:
|
||||
OutgoingRecord( RsGxsId rec, GxsTransSubServices cs,
|
||||
const uint8_t* data, uint32_t size );
|
||||
|
||||
virtual ~OutgoingRecord() {}
|
||||
|
||||
GxsTransSendStatus status;
|
||||
RsGxsId recipient;
|
||||
/// Don't use a pointer would be invalid after publish
|
||||
|
@ -194,10 +210,11 @@ private:
|
|||
};
|
||||
|
||||
|
||||
struct RsGxsTransSerializer : public RsServiceSerializer
|
||||
class RsGxsTransSerializer : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
RsGxsTransSerializer() : RsServiceSerializer(RS_SERVICE_TYPE_GXS_TRANS) {}
|
||||
~RsGxsTransSerializer() {}
|
||||
virtual ~RsGxsTransSerializer() {}
|
||||
|
||||
RsItem* create_item(uint16_t service_id, uint8_t item_sub_id) const
|
||||
{
|
||||
|
|
|
@ -2259,7 +2259,7 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
|
|||
msg_serialized_data, msg_serialized_rssize,
|
||||
signing_key_id, grouter_message_id );
|
||||
RsGxsTransId gxsMailId;
|
||||
mGxsTransServ.sendMail( gxsMailId, GxsTransSubServices::P3_MSG_SERVICE,
|
||||
mGxsTransServ.sendData( gxsMailId, GxsTransSubServices::P3_MSG_SERVICE,
|
||||
signing_key_id, destination_key_id,
|
||||
msg_serialized_data, msg_serialized_rssize );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue