mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-18 03:19:30 -04:00
added backend for distant message and distant chat filtering based on contact list
This commit is contained in:
parent
f5c2aa31e3
commit
140205108a
20 changed files with 373 additions and 180 deletions
|
@ -42,37 +42,41 @@ static const uint32_t GROUTER_CLIENT_SERVICE_DATA_STATUS_FAILED = 0x0002 ; //
|
|||
|
||||
class GRouterClientService
|
||||
{
|
||||
public:
|
||||
// This method is called by the turtle router to send data that comes out of a turtle tunnel.
|
||||
// The turtle router stays responsible for the memory management of data. Most of the time the
|
||||
// data chunk is a serialized item to be de-serialized by the client service.
|
||||
//
|
||||
// Parameters:
|
||||
// item : global router item. Handled by the client service.
|
||||
// destination_key : key that is associated with this item. Can be useful for the client.
|
||||
//
|
||||
// GRouter stays owner of the item, so the client should not delete it!
|
||||
//
|
||||
virtual void receiveGRouterData(const RsGxsId& destination_key,const RsGxsId& /*signing_key*/, GRouterServiceId &/*client_id*/, uint8_t */*data*/, uint32_t /*data_size*/)
|
||||
{
|
||||
std::cerr << "!!!!!! Received Data from global router, but the client service is not handling it !!!!!!!!!!" << std::endl ;
|
||||
std::cerr << " destination key_id = " << destination_key.toStdString() << std::endl;
|
||||
}
|
||||
public:
|
||||
// This method is called by the turtle router to send data that comes out of a turtle tunnel.
|
||||
// The turtle router stays responsible for the memory management of data. Most of the time the
|
||||
// data chunk is a serialized item to be de-serialized by the client service.
|
||||
//
|
||||
// Parameters:
|
||||
// item : global router item. Handled by the client service.
|
||||
// destination_key : key that is associated with this item. Can be useful for the client.
|
||||
//
|
||||
// GRouter stays owner of the item, so the client should not delete it!
|
||||
//
|
||||
virtual void receiveGRouterData(const RsGxsId& destination_key,const RsGxsId& /*signing_key*/, GRouterServiceId &/*client_id*/, uint8_t */*data*/, uint32_t /*data_size*/)
|
||||
{
|
||||
std::cerr << "!!!!!! Received Data from global router, but the client service is not handling it !!!!!!!!!!" << std::endl ;
|
||||
std::cerr << " destination key_id = " << destination_key.toStdString() << std::endl;
|
||||
}
|
||||
|
||||
// This method is called by the global router when a message has been received, or cannot be sent, etc.
|
||||
//
|
||||
virtual void notifyDataStatus(const GRouterMsgPropagationId& received_id,uint32_t data_status)
|
||||
{
|
||||
std::cerr << "!!!!!! Received Data status from global router, but the client service is not handling it !!!!!!!!!!" << std::endl ;
|
||||
std::cerr << " message ID = " << received_id << std::endl;
|
||||
std::cerr << " data status = " << data_status << std::endl;
|
||||
}
|
||||
// This method is called by the global router when a message has been received, or cannot be sent, etc.
|
||||
//
|
||||
virtual void notifyDataStatus(const GRouterMsgPropagationId& received_id,uint32_t data_status)
|
||||
{
|
||||
std::cerr << "!!!!!! Received Data status from global router, but the client service is not handling it !!!!!!!!!!" << std::endl ;
|
||||
std::cerr << " message ID = " << received_id << std::endl;
|
||||
std::cerr << " data status = " << data_status << std::endl;
|
||||
}
|
||||
|
||||
// This function is mandatory. It should do two things:
|
||||
// 1 - keep a pointer to the global router, so as to be able to send data (e.g. copy pt into a local variable)
|
||||
// 2 - call pt->registerTunnelService(this), so that the TR knows that service and can send back information to it.
|
||||
//
|
||||
virtual void connectToGlobalRouter(p3GRouter *pt) = 0 ;
|
||||
// This function is mandatory. It should do two things:
|
||||
// 1 - keep a pointer to the global router, so as to be able to send data (e.g. copy pt into a local variable)
|
||||
// 2 - call pt->registerTunnelService(this), so that the TR knows that service and can send back information to it.
|
||||
//
|
||||
virtual void connectToGlobalRouter(p3GRouter *pt) = 0 ;
|
||||
|
||||
// should be derived to determine wether the client accepts data from this peer or not. If not, the data is dropped.
|
||||
|
||||
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id) =0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1661,10 +1661,13 @@ void p3GRouter::handleIncomingDataItem(RsGRouterGenericDataItem *data_item)
|
|||
|
||||
std::cerr << " notyfying client." << std::endl;
|
||||
#endif
|
||||
client->receiveGRouterData(decrypted_item->destination_key,decrypted_item->signature.keyId,service_id,decrypted_item->data_bytes,decrypted_item->data_size);
|
||||
|
||||
decrypted_item->data_bytes = NULL ;
|
||||
decrypted_item->data_size = 0 ;
|
||||
if(client->acceptDataFromPeer(decrypted_item->signature.keyId))
|
||||
{
|
||||
client->receiveGRouterData(decrypted_item->destination_key,decrypted_item->signature.keyId,service_id,decrypted_item->data_bytes,decrypted_item->data_size);
|
||||
|
||||
decrypted_item->data_bytes = NULL ;
|
||||
decrypted_item->data_size = 0 ;
|
||||
}
|
||||
|
||||
delete decrypted_item ;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue