From cebe1f1055808b8a24198962bf73f091a1f8c933 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 11 Jun 2013 09:14:28 +0200 Subject: [PATCH] start privacy impelmentation --- coreapi/linphonecall.c | 17 ++++++++++++----- coreapi/linphonecore.c | 1 + coreapi/linphonecore.h | 35 +++++++++++++++++++++++++++++------ coreapi/private.h | 5 ++++- tester/call_tester.c | 4 ++-- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 55dca4762..ef97be71e 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1141,13 +1141,20 @@ void _linphone_call_params_copy(LinphoneCallParams *ncp, const LinphoneCallParam if (cp->custom_headers) ncp->custom_headers=sal_custom_header_clone(cp->custom_headers); } -void linphone_call_params_enable_privacy(LinphoneCallParams *params, bool_t enable) { - params->privacy_enabled=enable; +void linphone_call_params_set_privacy(LinphoneCallParams *params, LinphonePrivacy privacy) { + params->privacy=privacy; } -bool_t linphone_call_params_privacy_enabled(const LinphoneCallParams *params) { - return params->privacy_enabled; +LinphonePrivacy linphone_call_params_get_privacy(const LinphoneCallParams *params) { + return params->privacy; +} +const char* linphone_privacy_to_string(LinphonePrivacy privacy) { + switch(privacy) { + case LinphonePrivacyDefault: return "LinphonePrivacyDefault"; + case LinphonePrivacyId: return "LinphonePrivacyId"; + case LinphonePrivacyNone: return "LinphonePrivacyNone"; + default: return "Unknown privacy mode"; + } } - /** * Copy existing LinphoneCallParams to a new LinphoneCallParams object. **/ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 13529889e..7ecc917b2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5888,6 +5888,7 @@ void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *para params->has_video=linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate; params->media_encryption=linphone_core_get_media_encryption(lc); params->in_conference=FALSE; + params->privacy=LinphonePrivacyNone; } void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 6848b4f43..9e82de6c7 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -280,20 +280,43 @@ LINPHONE_PUBLIC void linphone_call_params_set_record_file(LinphoneCallParams *cp LINPHONE_PUBLIC const char *linphone_call_params_get_record_file(const LinphoneCallParams *cp); LINPHONE_PUBLIC void linphone_call_params_add_custom_header(LinphoneCallParams *params, const char *header_name, const char *header_value); LINPHONE_PUBLIC const char *linphone_call_params_get_custom_header(const LinphoneCallParams *params, const char *header_name); +/*** + * @ingroup call_control + * Defines privacy policy to apply as described by rfc3325 + * */ +typedef enum _LinphonePrivacy { + /** + * Default privacy as defined either globally or by proxy using #linphone_proxy_config_set_privacy + */ + LinphonePrivacyDefault, + /** + * With this mode, "from" header is hidden, usually replaced by From: "Anonymous" + */ + LinphonePrivacyId, + /** + * No privacy action are taken + */ + LinphonePrivacyNone +} LinphonePrivacy; /** * @ingroup call_control - * indicates if from must be replaced by anonymous value as described by rfc3325. + * @return string value of LinphonePrivacy enum + * */ +const char* linphone_privacy_to_string(LinphonePrivacy privacy); +/** + * @ingroup call_control + * Indicates if "from" must be replaced by anonymous value as described by rfc3325. * @param params to be modified - * @param enable TRUE to enable privacy + * @param LinphonePrivacy to configure privacy * */ -LINPHONE_PUBLIC void linphone_call_params_enable_privacy(LinphoneCallParams *params, bool_t enable); +LINPHONE_PUBLIC void linphone_call_params_set_privacy(LinphoneCallParams *params, LinphonePrivacy privacy); /** * @ingroup call_control - * indicates if from must be replaced by anonymous value as described by rfc3325. + * indicates if "from" must be replaced by anonymous value as described by rfc3325. * @param params object - * @return TRUE if privacy enabled + * @return Privacy mode * */ -LINPHONE_PUBLIC bool_t linphone_call_params_privacy_enabled(const LinphoneCallParams *params); +LINPHONE_PUBLIC LinphonePrivacy linphone_call_params_get_privacy(const LinphoneCallParams *params); struct _LinphoneInfoMessage; diff --git a/coreapi/private.h b/coreapi/private.h index 7af6b302d..db628274b 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -74,6 +74,9 @@ extern "C" { #endif #endif +struct LinphoneParams { + +}; struct _LinphoneCallParams{ LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */ int audio_bw; /* bandwidth limit for audio stream */ @@ -91,7 +94,7 @@ struct _LinphoneCallParams{ bool_t in_conference; /*in conference mode */ bool_t pad; bool_t low_bandwidth; - bool_t privacy_enabled; + LinphonePrivacy privacy; }; struct _LinphoneCallLog{ diff --git a/tester/call_tester.c b/tester/call_tester.c index f67b70d0a..f075add6a 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -615,7 +615,7 @@ static void call_with_privacy(void) { LinphoneCallParams *params; params=linphone_core_create_default_call_parameters(pauline->lc); - linphone_call_params_enable_privacy(params,TRUE); + linphone_call_params_set_privacy(params,LinphonePrivacyId); CU_ASSERT_TRUE(call_with_params(pauline,marie,params)); linphone_call_params_destroy(params); @@ -632,7 +632,7 @@ static void call_with_privacy(void) { /*make sure remote identity is hidden*/ CU_ASSERT_FALSE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline->identity)); - CU_ASSERT_TRUE(linphone_call_params_privacy_enabled(linphone_call_get_current_params(c2))); + CU_ASSERT_EQUAL(linphone_call_params_get_privacy(linphone_call_get_current_params(c2)),LinphonePrivacyId); /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc);