Commit 033a2472 authored by Matthieu Tanon's avatar Matthieu Tanon
Browse files

Allow local LIMEv2 databases removal from tester

parent 28ec7899
......@@ -1540,6 +1540,13 @@ LINPHONE_PUBLIC bool_t linphone_core_lime_v2_enabled(const LinphoneCore *lc);
**/
LINPHONE_PUBLIC bool_t linphone_core_lime_v2_available(const LinphoneCore *lc);
/**
* Deletes local LIMEv2 database
* @param[in] lc LinphoneCore object
* @ingroup network_parameters
**/
LINPHONE_PUBLIC void linphone_core_delete_local_lime_v2_db(const LinphoneCore *lc);
/**
* Tells whether IPv6 is enabled or not.
* @param[in] lc #LinphoneCore object
......
......@@ -84,3 +84,7 @@ bool_t linphone_core_lime_v2_enabled (const LinphoneCore *lc) {
bool_t linphone_core_lime_v2_available (const LinphoneCore *lc) {
return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->limeV2Available();
}
void linphone_core_delete_local_lime_v2_db (const LinphoneCore *lc) {
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getEncryptionEngine()->cleanDb();
}
......@@ -20,16 +20,12 @@
#ifndef _L_ENCRYPTION_ENGINE_LISTENER_H_
#define _L_ENCRYPTION_ENGINE_LISTENER_H_
// system includes
#include <memory>
// include includes
#include "chat/chat-room/abstract-chat-room.h"
#include "chat/modifier/chat-message-modifier.h"
#include "linphone/lpconfig.h"
// local includes
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
......@@ -42,8 +38,8 @@ public:
enum class EngineType {
Undefined = -1,
LimeV2 = 0,
Another = 1,
YetAnother = 2
//Another = 1,
//YetAnother = 2
};
virtual ~EncryptionEngineListener () = default;
......@@ -57,6 +53,7 @@ public:
virtual int uploadingFile (const std::shared_ptr<ChatMessage> &message, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encryptedBuffer) { return 0; }
virtual EncryptionEngineListener::EngineType getEngineType () { return EngineType::Undefined; }
virtual AbstractChatRoom::SecurityLevel getSecurityLevel (std::string deviceId) const { return AbstractChatRoom::SecurityLevel::Unsafe; }
virtual void cleanDb () {}
protected:
EncryptionEngineListener::EngineType engineType;
......
......@@ -130,4 +130,6 @@ int LimeBackwardsCompatible::uploadingFile (const shared_ptr<ChatMessage> &messa
return -1;
}
void LimeBackwardsCompatible::cleanDb () {}
LINPHONE_END_NAMESPACE
......@@ -34,6 +34,7 @@ public:
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;
void cleanDb () override;
};
LINPHONE_END_NAMESPACE
......
......@@ -81,7 +81,7 @@ void BelleSipLimeManager::processAuthRequested (void *data, belle_sip_auth_event
}
}
BelleSipLimeManager::BelleSipLimeManager (const string &db_access, belle_http_provider_t *prov, LinphoneCore *lc) : LimeManager(db_access, [prov, lc](const string &url, const string &from, const vector<uint8_t> &message, const lime::limeX3DHServerResponseProcess &responseProcess) {
BelleSipLimeManager::BelleSipLimeManager (const string &dbAccess, belle_http_provider_t *prov, LinphoneCore *lc) : LimeManager(dbAccess, [prov, lc](const string &url, const string &from, const vector<uint8_t> &message, const lime::limeX3DHServerResponseProcess &responseProcess) {
belle_http_request_listener_callbacks_t cbs= {};
belle_http_request_listener_t *l;
belle_generic_uri_t *uri;
......@@ -107,11 +107,12 @@ BelleSipLimeManager::BelleSipLimeManager (const string &db_access, belle_http_pr
}) {
}
LimeV2::LimeV2 (const std::string &db_access, belle_http_provider_t *prov, LinphoneCore *lc) {
LimeV2::LimeV2 (const std::string &dbAccess, belle_http_provider_t *prov, LinphoneCore *lc) {
engineType = EncryptionEngineListener::EngineType::LimeV2;
x3dhServerUrl = linphone_config_get_string(linphone_core_get_config(lc), "misc", "x3dh_server_url", "");
curve = lime::CurveId::c25519; // c448
belleSipLimeManager = unique_ptr<BelleSipLimeManager>(new BelleSipLimeManager(db_access, prov, lc));
x3dhServerUrl = linphone_config_get_string(linphone_core_get_config(lc), "misc", "x3dh_server_url", "");
_dbAccess = dbAccess;
belleSipLimeManager = unique_ptr<BelleSipLimeManager>(new BelleSipLimeManager(dbAccess, prov, lc));
lastLimeUpdate = linphone_config_get_int(lc->config, "misc", "last_lime_update_time", 0);
}
......@@ -439,6 +440,10 @@ AbstractChatRoom::SecurityLevel LimeV2::getSecurityLevel (string deviceId) const
}
}
void LimeV2::cleanDb () {
remove(_dbAccess.c_str());
}
void LimeV2::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {
// TODO Work in progress
}
......
......@@ -83,6 +83,7 @@ public:
int uploadingFile (const std::shared_ptr<ChatMessage> &message, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer) override;
EncryptionEngineListener::EngineType getEngineType () override;
AbstractChatRoom::SecurityLevel getSecurityLevel (std::string deviceId) const override;
void cleanDb () override;
// CoreListener overrides
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
......@@ -92,6 +93,7 @@ private:
std::shared_ptr<BelleSipLimeManager> belleSipLimeManager;
std::time_t lastLimeUpdate;
std::string x3dhServerUrl;
std::string _dbAccess;
lime::CurveId curve;
};
......
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