mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Fixed CPIM tests
This commit is contained in:
parent
ae93514982
commit
0fcb6fe1dd
9 changed files with 63 additions and 5 deletions
|
|
@ -51,6 +51,8 @@ public:
|
|||
|
||||
typedef EnumMask<Capabilities> CapabilitiesMask;
|
||||
|
||||
virtual void allowCpim (bool value) = 0;
|
||||
virtual void allowMultipart (bool value) = 0;
|
||||
virtual bool canHandleCpim () const = 0;
|
||||
virtual bool canHandleMultipart () const = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ class LINPHONE_PUBLIC BasicChatRoom : public ChatRoom {
|
|||
friend class CorePrivate;
|
||||
|
||||
public:
|
||||
void allowCpim (bool value);
|
||||
void allowMultipart (bool value);
|
||||
void allowCpim (bool value) override;
|
||||
void allowMultipart (bool value) override;
|
||||
bool canHandleCpim () const override;
|
||||
bool canHandleMultipart () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -205,6 +205,14 @@ shared_ptr<Core> ClientGroupChatRoom::getCore () const {
|
|||
return ChatRoom::getCore();
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::allowCpim (bool value) {
|
||||
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::allowMultipart (bool value) {
|
||||
|
||||
}
|
||||
|
||||
bool ClientGroupChatRoom::canHandleCpim () const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ public:
|
|||
);
|
||||
|
||||
std::shared_ptr<Core> getCore () const;
|
||||
|
||||
|
||||
void allowCpim (bool value) override;
|
||||
void allowMultipart (bool value) override;
|
||||
bool canHandleCpim () const override;
|
||||
bool canHandleMultipart () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -298,6 +298,14 @@ const IdentityAddress &ProxyChatRoom::getConferenceAddress () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ProxyChatRoom::allowCpim (bool value) {
|
||||
|
||||
}
|
||||
|
||||
void ProxyChatRoom::allowMultipart (bool value) {
|
||||
|
||||
}
|
||||
|
||||
bool ProxyChatRoom::canHandleCpim () const {
|
||||
L_D();
|
||||
return d->chatRoom->canHandleCpim();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public:
|
|||
|
||||
const IdentityAddress &getConferenceAddress () const override;
|
||||
|
||||
void allowCpim (bool value) override;
|
||||
void allowMultipart (bool value) override;
|
||||
bool canHandleCpim () const override;
|
||||
bool canHandleMultipart () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,14 @@ ServerGroupChatRoom::CapabilitiesMask ServerGroupChatRoom::getCapabilities () co
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ServerGroupChatRoom::allowCpim (bool value) {
|
||||
|
||||
}
|
||||
|
||||
void ServerGroupChatRoom::allowMultipart (bool value) {
|
||||
|
||||
}
|
||||
|
||||
bool ServerGroupChatRoom::canHandleCpim () const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ public:
|
|||
|
||||
std::shared_ptr<Core> getCore () const;
|
||||
|
||||
void allowCpim (bool value) override;
|
||||
void allowMultipart (bool value) override;
|
||||
bool canHandleCpim () const override;
|
||||
bool canHandleMultipart () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -389,17 +389,40 @@ static void build_message () {
|
|||
BC_ASSERT_STRING_EQUAL(strMessage.c_str(), expectedMessage.c_str());
|
||||
}
|
||||
|
||||
static int fake_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), ContentType::Cpim.asString().c_str()); // Encryption is the first receiving step, so this message should be CPIM
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int fake_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), ContentType::Cpim.asString().c_str()); // Encryption is the last sending step, so this message should be CPIM
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void cpim_chat_message_modifier_base(bool_t use_multipart) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
|
||||
LpConfig *config = linphone_core_get_config(marie->lc);
|
||||
|
||||
// We use a fake encryption engine just to check the internal content type during the sending/receiving process
|
||||
LinphoneImEncryptionEngine *marie_imee = linphone_im_encryption_engine_new();
|
||||
LinphoneImEncryptionEngineCbs *marie_cbs = linphone_im_encryption_engine_get_callbacks(marie_imee);
|
||||
LinphoneImEncryptionEngine *pauline_imee = linphone_im_encryption_engine_new();
|
||||
LinphoneImEncryptionEngineCbs *pauline_cbs = linphone_im_encryption_engine_get_callbacks(pauline_imee);
|
||||
linphone_im_encryption_engine_cbs_set_process_outgoing_message(marie_cbs, fake_im_encryption_engine_process_outgoing_message_cb);
|
||||
linphone_im_encryption_engine_cbs_set_process_incoming_message(pauline_cbs, fake_im_encryption_engine_process_incoming_message_cb);
|
||||
linphone_core_set_im_encryption_engine(marie->lc, marie_imee);
|
||||
linphone_core_set_im_encryption_engine(pauline->lc, pauline_imee);
|
||||
|
||||
lp_config_set_int(config, "sip", "use_cpim", 1);
|
||||
|
||||
IdentityAddress paulineAddress(linphone_address_as_string_uri_only(pauline->identity));
|
||||
shared_ptr<AbstractChatRoom> marieRoom = marie->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress);
|
||||
marieRoom->allowCpim(true);
|
||||
|
||||
shared_ptr<ChatMessage> marieMessage = marieRoom->createChatMessage("Hello CPIM");
|
||||
if (use_multipart) {
|
||||
marieRoom->allowMultipart(true);
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::PlainText);
|
||||
content->setBody("Hello Part 2");
|
||||
|
|
@ -408,14 +431,17 @@ static void cpim_chat_message_modifier_base(bool_t use_multipart) {
|
|||
marieMessage->send();
|
||||
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1));
|
||||
BC_ASSERT_TRUE(marieMessage->getInternalContent().getContentType() == ContentType::Cpim);
|
||||
BC_ASSERT_STRING_EQUAL(marieMessage->getInternalContent().getContentType().asString().c_str(), ""); // Internal content is cleaned after message is sent or received
|
||||
|
||||
BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message);
|
||||
if (pauline->stat.last_received_chat_message != NULL) {
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline->stat.last_received_chat_message), "Hello CPIM");
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), "text/plain");
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), ContentType::PlainText.asString().c_str());
|
||||
}
|
||||
|
||||
linphone_im_encryption_engine_unref(marie_imee);
|
||||
linphone_im_encryption_engine_unref(pauline_imee);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue