diff --git a/coreapi/chat.c b/coreapi/chat.c index e25eecb25..3f9d6692c 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -264,6 +264,10 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c return _linphone_core_get_or_create_chat_room(lc, to); } +bool_t linphone_chat_room_lime_enabled(LinphoneChatRoom *cr) { + return linphone_core_lime_enabled(cr->lc) != LinphoneLimeDisabled/*&& TODO: check that cr->peer_url has a verified token */; +} + static void linphone_chat_room_delete_composing_idle_timer(LinphoneChatRoom *cr) { if (cr->composing_idle_timer) { if (cr->lc && cr->lc->sal) @@ -377,7 +381,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage char *peer_uri = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr)); const char *content_type; - if (linphone_core_lime_enabled(cr->lc)) { + if (linphone_chat_room_lime_enabled(cr)) { /* ref the msg or it may be destroyed by callback if the encryption failed */ if (msg->content_type && strcmp(msg->content_type, "application/vnd.gsma.rcs-ft-http+xml") == 0) { /* it's a file transfer, content type shall be set to diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 4dc39ec07..e4c55f152 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -172,7 +172,8 @@ static void linphone_chat_message_process_response_from_post_file(void *data, belle_sip_body_handler_t *first_part_bh; /* shall we encrypt the file */ - if (linphone_core_lime_for_file_sharing_enabled(msg->chat_room->lc)) { + if (linphone_chat_room_lime_enabled(msg->chat_room) && + linphone_core_lime_for_file_sharing_enabled(msg->chat_room->lc)) { char keyBuffer [FILE_TRANSFER_KEY_SIZE]; /* temporary storage of generated key: 192 bits of key + 64 bits of initial vector */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 375ad5a56..a39f28447 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1856,18 +1856,22 @@ bool_t linphone_core_get_guess_hostname(LinphoneCore *lc){ return lc->sip_conf.guess_hostname; } -void linphone_core_enable_lime(LinphoneCore *lc, bool_t val){ +void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ if (linphone_core_ready(lc)){ lp_config_set_int(lc->config,"sip","lime",val); } } -bool_t linphone_core_lime_enabled(const LinphoneCore *lc){ - return (lp_config_get_int(lc->config,"sip", "lime", FALSE) && lime_is_available()); +LinphoneLimeState linphone_core_lime_enabled(const LinphoneCore *lc){ + return lime_is_available() ? lp_config_get_int(lc->config,"sip", "lime", LinphoneLimeDisabled) : LinphoneLimeDisabled; } -bool_t linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc){ - return linphone_core_lime_enabled(lc) && (lp_config_get_int(lc->config,"sip", "lime_for_file_sharing", TRUE) && lime_is_available()); +LinphoneLimeState linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc){ + LinphoneLimeState s = linphone_core_lime_enabled(lc); + if (s != LinphoneLimeDisabled) { + s = lp_config_get_int(lc->config,"sip", "lime_for_file_sharing", LinphoneLimeMandatory); + } + return s; } LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc){ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 42d326353..6494848fe 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1241,6 +1241,12 @@ typedef enum _LinphoneChatMessageState { LinphoneChatMessageStateFileTransferDone /**< File transfer has been completed successfully. */ } LinphoneChatMessageState; +typedef enum _LinphoneLimeState { + LinphoneLimeDisabled, /**< Lime is not used at all */ + LinphoneLimeMandatory, /**< Lime is always used */ + LinphoneLimePreferred, /**< Lime is used only if we already shared a secret with remote */ +} LinphoneLimeState; + /** * Call back used to notify message delivery status * @param msg #LinphoneChatMessage object @@ -2566,8 +2572,8 @@ LINPHONE_PUBLIC bool_t linphone_core_get_guess_hostname(LinphoneCore *lc); * Tells to LinphoneCore to use Linphone Instant Messaging encryption * */ -LINPHONE_PUBLIC void linphone_core_enable_lime(LinphoneCore *lc, bool_t val); -LINPHONE_PUBLIC bool_t linphone_core_lime_enabled(const LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val); +LINPHONE_PUBLIC LinphoneLimeState linphone_core_lime_enabled(const LinphoneCore *lc); LINPHONE_PUBLIC bool_t linphone_core_ipv6_enabled(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val); diff --git a/coreapi/private.h b/coreapi/private.h index a041c8126..7c9bfbb12 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -153,16 +153,16 @@ struct _LinphoneCallParams{ bool_t has_video; bool_t avpf_enabled; /* RTCP feedback messages are enabled */ bool_t implicit_rtcp_fb; - + bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t in_conference; /*in conference mode */ bool_t low_bandwidth; bool_t no_user_consent;/*when set to TRUE an UPDATE request will be used instead of reINVITE*/ - + uint16_t avpf_rr_interval; /*in milliseconds*/ bool_t internal_call_update; /*use mark that call update was requested internally (might be by ice) - unused for the moment*/ bool_t video_multicast_enabled; - + bool_t audio_multicast_enabled; bool_t realtimetext_enabled; bool_t update_call_when_ice_completed; @@ -356,7 +356,7 @@ struct _LinphoneCall{ bool_t paused_by_app; bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */ - + LinphoneConference *conf_ref; /**> Point on the associated conference if this call is part of a conference. NULL instead. */ }; @@ -399,7 +399,7 @@ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj); void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc); void _linphone_proxy_config_release(LinphoneProxyConfig *cfg); void _linphone_proxy_config_unpublish(LinphoneProxyConfig *obj); - + /* * returns service route as defined in as defined by rfc3608, might be a list instead of just one. * Can be NULL @@ -574,6 +574,7 @@ int linphone_chat_room_upload_file(LinphoneChatMessage *msg); void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg); LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void); LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call); +bool_t linphone_chat_room_lime_enabled(LinphoneChatRoom *cr); /**/ struct _LinphoneProxyConfig @@ -930,12 +931,12 @@ struct _LinphoneCore bool_t auto_net_state_mon; bool_t sip_network_reachable; bool_t media_network_reachable; - + bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/ bool_t use_preview_window; bool_t network_last_status; bool_t ringstream_autorelease; - + bool_t vtables_running; bool_t send_call_stats_periodical_updates; bool_t forced_ice_relay; @@ -1440,14 +1441,14 @@ LINPHONE_PUBLIC void _linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreV LINPHONE_PUBLIC MSWebCam *linphone_call_get_video_device(const LinphoneCall *call); MSWebCam *get_nowebcam_device(MSFactory *f); #endif -bool_t linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc); +LinphoneLimeState linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc); BELLE_SIP_DECLARE_VPTR(LinphoneTunnelConfig); int linphone_core_get_default_proxy_config_index(LinphoneCore *lc); char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ; - + #ifdef __cplusplus } #endif