Commit 57be0bf6 authored by Matthieu Tanon's avatar Matthieu Tanon

Code clean and renaming

parent c459d271
......@@ -144,6 +144,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_acc
* Send an XML-RPC request to delete a Linphone account.
* @param[in] creator LinphoneAccountCreator object
* @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
* @donotwrap
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_delete_account_linphone(LinphoneAccountCreator *creator);
......@@ -172,6 +173,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account
* Send an XML-RPC request to get the confirmation key of a Linphone account.
* @param[in] creator LinphoneAccountCreator object
* @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
* @donotwrap
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_get_confirmation_key_linphone(LinphoneAccountCreator *creator);
......
......@@ -187,36 +187,35 @@ typedef void (*LinphoneChatRoomCbsMessageReceivedCb) (LinphoneChatRoom *cr, Linp
/**
* Callback used to notify a chat room that a chat message has been received.
* @param[in] cr #LinphoneChatRoom object
* @param[in] event_log The #LinphoneChatMessage event log that has been received
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsChatMessageReceivedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room that a chat message is being sent.
* @param[in] cr #LinphoneChatRoom object
* @param[in] event_log The #LinphoneChatMessage event log that is being sent
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsChatMessageSentCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room that a participant has been added.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participant The #LinphoneParticipant that has been added to the chat room
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsParticipantAddedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room that a participant has been removed.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participant The #LinphoneParticipant that has been removed from the chat room
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsParticipantRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room that the admin status of a participant has been changed.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participant The #LinphoneParticipant for which the admin status has been changed
* @param[in] isAdmin The new admin status of the participant
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsParticipantAdminStatusChangedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
......@@ -230,14 +229,14 @@ typedef void (*LinphoneChatRoomCbsStateChangedCb) (LinphoneChatRoom *cr, Linphon
/**
* Callback used to notify a security event in the chat room.
* @param[in] cr #LinphoneChatRoom object
* @param[in] securityEventType the security event type
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsSecurityEventCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify that the subject of a chat room has changed.
* @param[in] cr #LinphoneChatRoom object
* @param[in] subject The new subject of the chat room
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsSubjectChangedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
......@@ -251,26 +250,28 @@ typedef void (*LinphoneChatRoomCbsUndecryptableMessageReceivedCb) (LinphoneChatR
/**
* Callback used to notify a chat room that a participant has been added.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participant The #LinphoneParticipant that has been added to the chat room
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsParticipantDeviceAddedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room that a participant has been removed.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participant The #LinphoneParticipant that has been removed from the chat room
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room has been joined.
* @param[in] cr #LinphoneChatRoom object
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsConferenceJoinedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *eventLog);
/**
* Callback used to notify a chat room has been left.
* @param[in] cr #LinphoneChatRoom object
* @param[in] event_log #LinphoneEventLog The event to be notified
*/
typedef void (*LinphoneChatRoomCbsConferenceLeftCb) (LinphoneChatRoom *cr, const LinphoneEventLog *eventLog);
......
......@@ -23,9 +23,9 @@
// =============================================================================
#define L_ENUM_VALUES_ENCRYPTION_ENGINE_SECURITY_LEVEL(F) \
F(Unsafe /**< Fail */) \
F(Unsafe /**< Security failure */) \
F(ClearText /**< No encryption */) \
F(Encrypted /**< Encrypted */) \
F(Safe /**< Encrypted and Verified */)
F(Safe /**< Encrypted and verified */)
#endif // ifndef _L_ENCRYPTION_ENGINE_ENUMS_H_
......@@ -23,7 +23,7 @@
// =============================================================================
#define L_ENUM_VALUES_SECURITY_EVENT_TYPE(F) \
F(Null /**< Event is not a security event */) \
F(None /**< Event is not a security event */) \
F(SecurityLevelDowngraded /**< Chatroom security level downgraded event */) \
F(ParticipantMaxDeviceCountExceeded /**< Participant has exceeded the maximum number of device event */) \
F(LimeIdentityKeyChanged /**< Peer device lime identity key has changed event */) \
......
......@@ -323,7 +323,7 @@ const LinphoneAddress *linphone_event_log_get_device_address (const LinphoneEven
LINPHONE_PUBLIC LinphoneSecurityEventType linphone_event_log_get_security_event_type (const LinphoneEventLog *event_log) {
if (!isConferenceSecurityType(linphone_event_log_get_type(event_log)))
return LinphoneSecurityEventTypeNull;
return LinphoneSecurityEventTypeNone;
const auto securityEvent = static_pointer_cast<const LinphonePrivate::ConferenceSecurityEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
......
......@@ -56,7 +56,7 @@ public:
int &errorCode
) { return ChatMessageModifier::Result::Skipped; }
virtual bool encryptionEnabledForFileTransfer (
virtual bool isEncryptionEnabledForFileTransfer (
const std::shared_ptr<AbstractChatRoom> &ChatRoom
) { return false; }
......
......@@ -89,7 +89,7 @@ ChatMessageModifier::Result LimeLegacyEncryptionEngine::processIncomingMessage (
return ChatMessageModifier::Result::Done;
}
bool LimeLegacyEncryptionEngine::encryptionEnabledForFileTransfer (const shared_ptr<AbstractChatRoom> &chatRoom) {
bool LimeLegacyEncryptionEngine::isEncryptionEnabledForFileTransfer (const shared_ptr<AbstractChatRoom> &chatRoom) {
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(chatRoom->getCore()->getCCore());
LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee);
LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer_cb =
......
......@@ -32,7 +32,7 @@ public:
ChatMessageModifier::Result processIncomingMessage (const std::shared_ptr<ChatMessage> &message, int &errorCode) override;
ChatMessageModifier::Result processOutgoingMessage (const std::shared_ptr<ChatMessage> &message, int &errorCode) override;
bool encryptionEnabledForFileTransfer (const std::shared_ptr<AbstractChatRoom> &ChatRoom) override;
bool isEncryptionEnabledForFileTransfer (const std::shared_ptr<AbstractChatRoom> &ChatRoom) override;
void generateFileTransferKey (const std::shared_ptr<AbstractChatRoom> &ChatRoom, const std::shared_ptr<ChatMessage> &message) override;
int downloadingFile (const std::shared_ptr<ChatMessage> &message, size_t offset, const uint8_t *buffer, size_t size, uint8_t *decrypted_buffer) override;
int uploadingFile (const std::shared_ptr<ChatMessage> &message, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer) override;
......
......@@ -399,7 +399,7 @@ void LimeX3DHEncryptionEngine::update () {
lp_config_set_int(lpconfig, "lime", "last_lime_update_time", (int)lastLimeUpdate);
}
bool LimeX3DHEncryptionEngine::encryptionEnabledForFileTransfer (const shared_ptr<AbstractChatRoom> &chatRoom) {
bool LimeX3DHEncryptionEngine::isEncryptionEnabledForFileTransfer (const shared_ptr<AbstractChatRoom> &chatRoom) {
return true;
}
......@@ -684,7 +684,7 @@ void LimeX3DHEncryptionEngine::addSecurityEventInChatrooms (
}
}
shared_ptr<ConferenceSecurityEvent> LimeX3DHEncryptionEngine::onDeviceAdded(
shared_ptr<ConferenceSecurityEvent> LimeX3DHEncryptionEngine::onDeviceAdded (
const IdentityAddress &newDeviceAddr,
shared_ptr<Participant> participant,
const shared_ptr<AbstractChatRoom> &chatRoom,
......@@ -750,41 +750,40 @@ void LimeX3DHEncryptionEngine::onRegistrationStateChanged (
LinphoneRegistrationState state,
const string &message
) {
if (state == LinphoneRegistrationState::LinphoneRegistrationOk) {
if (state != LinphoneRegistrationState::LinphoneRegistrationOk)
return;
if (x3dhServerUrl.empty()) {
lError() << "LIMEv2 X3DH server URL unavailable for encryption engine: can't create lime user";
return;
}
if (x3dhServerUrl.empty()) {
lError() << "LIMEv2 X3DH server URL unavailable for encryption engine: can't create lime user";
return;
}
char *contactAddress = linphone_address_as_string_uri_only(linphone_proxy_config_get_contact(cfg));
IdentityAddress identityAddress = IdentityAddress(contactAddress);
string localDeviceId = identityAddress.asString();
if (contactAddress)
ms_free(contactAddress);
char *contactAddress = linphone_address_as_string_uri_only(linphone_proxy_config_get_contact(cfg));
IdentityAddress identityAddress = IdentityAddress(contactAddress);
string localDeviceId = identityAddress.asString();
if (contactAddress)
ms_free(contactAddress);
stringstream operation;
operation << "create user " << localDeviceId;
lime::limeCallback callback = setLimeCallback(operation.str());
stringstream operation;
operation << "create user " << localDeviceId;
lime::limeCallback callback = setLimeCallback(operation.str());
LinphoneConfig *lpconfig = linphone_core_get_config(linphone_proxy_config_get_core(cfg));
lastLimeUpdate = linphone_config_get_int(lpconfig, "lime", "last_lime_update_time", -1);
LinphoneConfig *lpconfig = linphone_core_get_config(linphone_proxy_config_get_core(cfg));
lastLimeUpdate = linphone_config_get_int(lpconfig, "lime", "last_lime_update_time", -1);
try {
// create user if not exist
belleSipLimeManager->create_user(localDeviceId, x3dhServerUrl, curve, callback);
lastLimeUpdate = ms_time(NULL);
lp_config_set_int(lpconfig, "lime", "last_lime_update_time", (int)lastLimeUpdate);
} catch (const exception &e) {
lInfo() << e.what() << " while creating lime user";
try {
// create user if not exist
belleSipLimeManager->create_user(localDeviceId, x3dhServerUrl, curve, callback);
lastLimeUpdate = ms_time(NULL);
lp_config_set_int(lpconfig, "lime", "last_lime_update_time", (int)lastLimeUpdate);
} catch (const exception &e) {
lInfo() << e.what() << " while creating lime user";
// update keys if necessary
int limeUpdateThreshold = lp_config_get_int(lpconfig, "lime", "lime_update_threshold", 86400); // 24 hours = 86400 s
if (ms_time(NULL) - lastLimeUpdate > limeUpdateThreshold) {
update();
lastLimeUpdate = ms_time(NULL);
} else {
}
// update keys if necessary
int limeUpdateThreshold = lp_config_get_int(lpconfig, "lime", "lime_update_threshold", 86400); // 24 hours = 86400 s
if (ms_time(NULL) - lastLimeUpdate > limeUpdateThreshold) {
update();
lastLimeUpdate = ms_time(NULL);
}
}
}
......
......@@ -140,7 +140,7 @@ public:
ChatRoom::SecurityLevel currentSecurityLevel
) override;
bool encryptionEnabledForFileTransfer (const std::shared_ptr<AbstractChatRoom> &ChatRoom) override;
bool isEncryptionEnabledForFileTransfer (const std::shared_ptr<AbstractChatRoom> &ChatRoom) override;
AbstractChatRoom::SecurityLevel getSecurityLevel (const std::string &deviceId) const override;
EncryptionEngine::EngineType getEngineType () override;
std::list<EncryptionParameter> getEncryptionParameters () override;
......
......@@ -196,12 +196,8 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptr<Ch
if (message->getPrivate()->senderAuthenticationEnabled) {
if (cpimFromAddress == message->getAuthenticatedFromAddress()) {
lInfo() << "[CPIM] Sender authentication successful";
cout << "[CPIM] Sender authentication successful" << endl;
} else {
lWarning() << "[CPIM] Sender authentication failed";
cout << "[CPIM] Sender authentication failed" << endl;
cout << "cpimFromAddress = " << cpimFromAddress.asString() << endl;
cout << "authFromAddress = " << message->getAuthenticatedFromAddress() << endl;
errorCode = 488;
return ChatMessageModifier::Result::Error;
}
......
......@@ -236,7 +236,7 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h
bool isFileEncryptionEnabled = false;
EncryptionEngine *imee = message->getCore()->getEncryptionEngine();
if (imee)
isFileEncryptionEnabled = imee->encryptionEnabledForFileTransfer(message->getChatRoom());
isFileEncryptionEnabled = imee->isEncryptionEnabledForFileTransfer(message->getChatRoom());
FileTransferContent *fileTransferContent = new FileTransferContent();
fileTransferContent->setContentType(ContentType::FileTransfer);
......
......@@ -109,7 +109,7 @@ static void chat_room_security_event (LinphoneChatRoom *cr, const LinphoneEventL
LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core);
switch (linphone_event_log_get_security_event_type(event_log)) {
case LinphoneSecurityEventTypeNull:
case LinphoneSecurityEventTypeNone:
break;
case LinphoneSecurityEventTypeSecurityLevelDowngraded:
manager->stat.number_of_SecurityLevelDowngraded++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment