|
|
@ -314,6 +314,36 @@ namespace pEp { |
|
|
|
_throw_status(status); |
|
|
|
} |
|
|
|
|
|
|
|
void Message::set_recv_by(Identity &new_recv_by) |
|
|
|
{ |
|
|
|
// Validate self and the new Recv-By identity.
|
|
|
|
::message *msg_c = _msg.get(); |
|
|
|
if (msg_c->dir != ::PEP_dir_incoming) { |
|
|
|
throw invalid_argument("message not incoming"); |
|
|
|
} |
|
|
|
if (new_recv_by.address().empty() || new_recv_by.user_id().empty()) { |
|
|
|
throw invalid_argument("identity incomplete"); |
|
|
|
} |
|
|
|
if (new_recv_by.user_id() != PEP_OWN_USERID) { |
|
|
|
throw invalid_argument("identity non-own"); |
|
|
|
} |
|
|
|
|
|
|
|
// Make a a copy of the given identity.
|
|
|
|
::pEp_identity *new_recv_by_c = new_recv_by; |
|
|
|
::pEp_identity *new_recv_by_copy_c = ::identity_dup(new_recv_by_c); |
|
|
|
if (new_recv_by_copy_c == NULL) { |
|
|
|
throw std::bad_alloc(); |
|
|
|
} |
|
|
|
// If we have not failed yet this will succeed.
|
|
|
|
|
|
|
|
// Destroy the old Recv-By.
|
|
|
|
::free_identity(msg_c->recv_by); |
|
|
|
msg_c->recv_by = NULL; |
|
|
|
|
|
|
|
// Use the copy as the new Recv-By.
|
|
|
|
msg_c->recv_by = new_recv_by_copy_c; |
|
|
|
} |
|
|
|
|
|
|
|
Message Message::encrypt() |
|
|
|
{ |
|
|
|
boost::python::list extra; |
|
|
|