Commit 5e714f46 authored by Sandrine Avakian's avatar Sandrine Avakian
Browse files

Merge branch 'master' of git.linphone.org:linphone into daemon

parents b077e3d6 e2609f96
......@@ -61,6 +61,30 @@ EXTRA_DIST = BUGS \
$(LINPHONEDEPS_FILELIST) \
$(ISS_SCRIPT).in
EXTRA_DIST += CMakeLists.txt \
cmake/FindGtkMacIntegration.cmake \
cmake/FindIconv.cmake \
cmake/FindIntl.cmake \
cmake/FindNotify.cmake \
cmake/FindSqlite3.cmake \
cmake/FindXML2.cmake \
cmake/FindZlib.cmake \
cmake/LinphoneConfig.cmake.in \
config.h.cmake \
console/CMakeLists.txt \
coreapi/CMakeLists.txt \
coreapi/gitversion.cmake \
coreapi/help/CMakeLists.txt \
gtk/CMakeLists.txt \
java/CMakeLists.txt \
pixmaps/CMakeLists.txt \
po/CMakeLists.txt \
share/CMakeLists.txt \
share/rings/CMakeLists.txt \
share/rootca.cmake \
tester/CMakeLists.txt \
tools/CMakeLists.txt
DISTCLEANFILES= $(ISS_SCRIPT) $(PACKAGE_WIN32_FILELIST)
CLEANFILES=Portfile Portfile-devel
......
......@@ -26,13 +26,16 @@
# ICONV_INCLUDE_DIRS - the libiconv include directory
# ICONV_LIBRARIES - The libraries needed to use libiconv
set(_ICONV_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
if(APPLE AND NOT IOS)
set(ICONV_HINTS "/usr")
endif()
if(ICONV_HINTS)
set(ICONV_LIBRARIES_HINTS "${ICONV_HINTS}/lib")
endif()
find_path(ICONV_INCLUDE_DIRS
NAMES iconv.h
HINTS _ICONV_ROOT_PATHS
HINTS "${ICONV_HINTS}"
PATH_SUFFIXES include
)
......@@ -42,8 +45,7 @@ endif()
find_library(ICONV_LIBRARIES
NAMES iconv
HINTS ${_ICONV_ROOT_PATHS}
PATH_SUFFIXES bin lib
HINTS "${ICONV_LIBRARIES_HINTS}"
)
include(FindPackageHandleStandardArgs)
......
......@@ -26,13 +26,16 @@
# SQLITE3_INCLUDE_DIRS - the sqlite3 include directory
# SQLITE3_LIBRARIES - The libraries needed to use sqlite3
set(_SQLITE3_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
if(APPLE AND NOT IOS)
set(SQLITE3_HINTS "/usr")
endif()
if(SQLITE3_HINTS)
set(SQLITE3_LIBRARIES_HINTS "${SQLITE3_HINTS}/lib")
endif()
find_path(SQLITE3_INCLUDE_DIRS
NAMES sqlite3.h
HINTS _SQLITE3_ROOT_PATHS
HINTS "${SQLITE3_HINTS}"
PATH_SUFFIXES include
)
......@@ -42,8 +45,7 @@ endif()
find_library(SQLITE3_LIBRARIES
NAMES sqlite3
HINTS ${_SQLITE3_ROOT_PATHS}
PATH_SUFFIXES bin lib
HINTS "${SQLITE3_LIBRARIES_HINTS}"
)
include(FindPackageHandleStandardArgs)
......
......@@ -26,13 +26,16 @@
# XML2_INCLUDE_DIRS - the libxml2 include directory
# XML2_LIBRARIES - The libraries needed to use libxml2
set(_XML2_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
if(APPLE AND NOT IOS)
set(XML2_HINTS "/usr")
endif()
if(XML2_HINTS)
set(XML2_LIBRARIES_HINTS "${XML2_HINTS}/lib")
endif()
find_path(XML2_INCLUDE_DIRS
NAMES libxml/xmlreader.h
HINTS _XML2_ROOT_PATHS
HINTS "${XML2_HINTS}"
PATH_SUFFIXES include/libxml2
)
......@@ -42,8 +45,7 @@ endif()
find_library(XML2_LIBRARIES
NAMES xml2
HINTS ${_XML2_ROOT_PATHS}
PATH_SUFFIXES bin lib
HINTS "${XML2_LIBRARIES_HINTS}"
)
include(FindPackageHandleStandardArgs)
......
......@@ -26,9 +26,16 @@
# ZLIB_INCLUDE_DIRS - the zlib include directory
# ZLIB_LIBRARIES - The libraries needed to use zlib
if(APPLE AND NOT IOS)
set(ZLIB_HINTS "/usr")
endif()
if(ZLIB_HINTS)
set(ZLIB_LIBRARIES_HINTS "${ZLIB_HINTS}/lib")
endif()
find_path(ZLIB_INCLUDE_DIRS
NAMES zlib.h
HINTS _ZLIB_ROOT_PATHS
HINTS "${ZLIB_HINTS}"
PATH_SUFFIXES include
)
......@@ -39,12 +46,12 @@ endif()
if(ENABLE_STATIC)
find_library(ZLIB_LIBRARIES
NAMES zstatic zlibstatic zlibstaticd z
PATH_SUFFIXES bin lib
HINTS "${ZLIB_LIBRARIES_HINTS}"
)
else()
find_library(ZLIB_LIBRARIES
NAMES z zlib zlibd
PATH_SUFFIXES bin lib
HINTS "${ZLIB_LIBRARIES_HINTS}"
)
endif()
......
......@@ -100,6 +100,15 @@ void TunnelManager::startClient() {
ms_message("TunnelManager: Starting tunnel client");
mTunnelClient = new TunnelClient(TRUE);
mTunnelClient->setCallback((TunnelClientController::StateCallback)tunnelCallback,this);
if (mVerifyServerCertificate) {
const char *rootCertificatePath = linphone_core_get_root_ca(mCore);
if (rootCertificatePath != NULL) {
ms_message("TunnelManager: Load root certificate from %s", rootCertificatePath);
mTunnelClient->setRootCertificate(rootCertificatePath); /* give the path to root certificate to the tunnel client in order to be able to verify the server certificate */
} else {
ms_warning("TunnelManager is set to verify server certificate but no root certificate is available in linphoneCore");
}
}
list<ServerAddr>::iterator it;
for(it=mServerAddrs.begin();it!=mServerAddrs.end();++it){
const ServerAddr &addr=*it;
......@@ -427,6 +436,14 @@ bool TunnelManager::tunnelizeSipPacketsEnabled() const {
return mTunnelizeSipPackets;
}
void TunnelManager::verifyServerCertificate(bool enable){
mVerifyServerCertificate = enable;
}
bool TunnelManager::verifyServerCertificateEnabled() const {
return mVerifyServerCertificate;
}
void TunnelManager::setHttpProxy(const char *host,int port, const char *username, const char *passwd){
mHttpUserName=username?username:"";
mHttpPasswd=passwd?passwd:"";
......
......@@ -110,6 +110,18 @@ namespace belledonnecomm {
* @return True, SIP packets pass through the tunnel
*/
bool tunnelizeSipPacketsEnabled() const;
/**
* Indicate to the tunnel manager wether server certificate
* must be verified during TLS handshake. Default: disabled
* @param enable If set to TRUE, SIP packets will pass through the tunnel.
* If set to FALSE, SIP packets will pass by the configured proxies.
*/
void verifyServerCertificate(bool enable);
/**
* Check wether the tunnel manager is set to verify server certificate during TLS handshake
* @return True, server certificate is verified(using the linphonecore root certificate)
*/
bool verifyServerCertificateEnabled() const;
/**
* @brief Constructor
* @param lc The LinphoneCore instance of which the TunnelManager will be associated to.
......@@ -188,6 +200,7 @@ namespace belledonnecomm {
LinphoneTunnelMode mMode;
State mState;
bool mTunnelizeSipPackets;
bool mVerifyServerCertificate;
TunnelClient* mTunnelClient;
std::string mHttpUserName;
std::string mHttpPasswd;
......
......@@ -501,6 +501,7 @@ Sal * sal_init(MSFactory *factory){
sal->refresher_retry_after=60000; /*default value in ms*/
sal->enable_sip_update=TRUE;
sal->pending_trans_checking=TRUE;
sal->ssl_config = NULL;
return sal;
}
......@@ -746,6 +747,7 @@ static void set_tls_properties(Sal *ctx){
else if (!ctx->tls_verify_cn) verify_exceptions = BELLE_TLS_VERIFY_CN_MISMATCH;
belle_tls_crypto_config_set_verify_exceptions(crypto_config, verify_exceptions);
if (ctx->root_ca != NULL) belle_tls_crypto_config_set_root_ca(crypto_config, ctx->root_ca);
if (ctx->ssl_config != NULL) belle_tls_crypto_config_set_ssl_config(crypto_config, ctx->ssl_config);
belle_sip_tls_listening_point_set_crypto_config(tlp, crypto_config);
belle_sip_object_unref(crypto_config);
}
......@@ -774,6 +776,12 @@ void sal_verify_server_cn(Sal *ctx, bool_t verify){
return ;
}
void sal_set_ssl_config(Sal *ctx, void *ssl_config) {
ctx->ssl_config = ssl_config;
set_tls_properties(ctx);
return ;
}
void sal_use_tcp_tls_keepalive(Sal *ctx, bool_t enabled) {
ctx->use_tcp_tls_keep_alive=enabled;
}
......
......@@ -53,6 +53,7 @@ struct Sal{
bool_t enable_sip_update; /*true by default*/
SalOpSDPHandling default_sdp_handling;
bool_t pending_trans_checking; /*testing purpose*/
void *ssl_config;
};
typedef enum SalOpState {
......
......@@ -47,7 +47,29 @@ void sal_add_presence_info(SalOp *op, belle_sip_message_t *notify, SalPresenceMo
}
static void presence_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
/*ms_error("presence_process_io_error not implemented yet");*/
SalOp* op = (SalOp*)user_ctx;
belle_sip_request_t* request;
belle_sip_client_transaction_t* client_transaction = NULL;
if (BELLE_SIP_OBJECT_IS_INSTANCE_OF(belle_sip_io_error_event_get_source(event),
belle_sip_client_transaction_t)){
client_transaction = (belle_sip_client_transaction_t*)belle_sip_io_error_event_get_source(event);
}
if (!client_transaction) return;
request = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction));
if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){
if (op->refresher){
ms_warning("presence_process_io_error() refresher is present, should not happen");
return;
}
ms_message("subscription to [%s] io error",sal_op_get_to(op));
if (!op->op_released){
op->base.root->callbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/
}
}
}
static void presence_process_dialog_terminated(void *ctx, const belle_sip_dialog_terminated_event_t *event) {
......@@ -81,6 +103,12 @@ static void presence_refresher_listener(belle_sip_refresher_t* refresher, void*
/*send a new SUBSCRIBE, that will attempt to establish a new dialog*/
sal_subscribe_presence(op,NULL,NULL,-1);
}
if (status_code == 0 || status_code == 503){
/*timeout or io error: the remote doesn't seem reachable.*/
if (!op->op_released){
op->base.root->callbacks.notify_presence(op,SalSubscribeActive, NULL,NULL); /*NULL = offline*/
}
}
}
......
......@@ -158,12 +158,12 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia
if (call->all_muted){
ms_message("Early media finished, unmuting inputs...");
/*we were in early media, now we want to enable real media */
linphone_call_enable_camera (call,linphone_call_camera_enabled (call));
call->all_muted = FALSE;
if (call->audiostream)
linphone_core_enable_mic(lc, linphone_core_mic_enabled(lc));
#ifdef VIDEO_ENABLED
if (call->videostream && call->camera_enabled)
video_stream_change_camera(call->videostream,linphone_call_get_video_device(call));
linphone_call_enable_camera(call, linphone_call_camera_enabled(call));
#endif
}
/*FIXME ZRTP, might be restarted in any cases ? */
......
......@@ -31,7 +31,7 @@ LinphoneCardDavContext* linphone_carddav_context_new(LinphoneFriendList *lfl) {
carddav_context = (LinphoneCardDavContext *)ms_new0(LinphoneCardDavContext, 1);
carddav_context->friend_list = linphone_friend_list_ref(lfl);
#else
ms_error("vCard isn't available (maybe it wasn't compiled), can't do CardDAV sync");
ms_error("[carddav] vCard isn't available (maybe it wasn't compiled), can't do CardDAV sync");
#endif
return carddav_context;
}
......@@ -64,7 +64,7 @@ static void linphone_carddav_sync_done(LinphoneCardDavContext *cdc, bool_t succe
ms_debug("CardDAV sync successful, saving new cTag: %i", cdc->ctag);
linphone_friend_list_update_revision(cdc->friend_list, cdc->ctag);
} else {
ms_error("CardDAV sync failure: %s", msg);
ms_error("[carddav] CardDAV sync failure: %s", msg);
}
if (cdc->sync_done_cb) {
......@@ -105,31 +105,38 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList *
linphone_vcard_set_url(lvc, full_url);
linphone_vcard_set_etag(lvc, vCard->etag);
ms_debug("Downloaded vCard etag/url are %s and %s", vCard->etag, full_url);
}
lf = linphone_friend_new_from_vcard(lvc);
local_friend = ms_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf);
if (local_friend) {
LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data;
lf->storage_id = lf2->storage_id;
lf->pol = lf2->pol;
lf->subscribe = lf2->subscribe;
lf->refkey = ms_strdup(lf2->refkey);
lf->presence_received = lf2->presence_received;
lf->lc = lf2->lc;
lf->friend_list = lf2->friend_list;
if (cdc->contact_updated_cb) {
ms_debug("Contact updated: %s", linphone_friend_get_name(lf));
cdc->contact_updated_cb(cdc, lf, lf2);
lf = linphone_friend_new_from_vcard(lvc);
if (lf) {
local_friend = ms_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf);
if (local_friend) {
LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data;
lf->storage_id = lf2->storage_id;
lf->pol = lf2->pol;
lf->subscribe = lf2->subscribe;
lf->refkey = ms_strdup(lf2->refkey);
lf->presence_received = lf2->presence_received;
lf->lc = lf2->lc;
lf->friend_list = lf2->friend_list;
if (cdc->contact_updated_cb) {
ms_debug("Contact updated: %s", linphone_friend_get_name(lf));
cdc->contact_updated_cb(cdc, lf, lf2);
}
} else {
if (cdc->contact_created_cb) {
ms_debug("Contact created: %s", linphone_friend_get_name(lf));
cdc->contact_created_cb(cdc, lf);
}
}
linphone_friend_unref(lf);
} else {
ms_error("[carddav] Couldn't create a friend from vCard");
}
} else {
if (cdc->contact_created_cb) {
ms_debug("Contact created: %s", linphone_friend_get_name(lf));
cdc->contact_created_cb(cdc, lf);
}
ms_error("[carddav] Couldn't parse vCard %s", vCard->vcard);
}
linphone_friend_unref(lf);
}
vCards = ms_list_next(vCards);
}
......@@ -367,7 +374,7 @@ static void process_response_from_carddav_request(void *data, const belle_http_r
linphone_carddav_sync_done(query->context, TRUE, NULL);
break;
default:
ms_error("Unknown request: %i", query->type);
ms_error("[carddav] Unknown request: %i", query->type);
break;
}
} else {
......@@ -383,7 +390,7 @@ static void process_response_from_carddav_request(void *data, const belle_http_r
static void process_io_error_from_carddav_request(void *data, const belle_sip_io_error_event_t *event) {
LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)data;
ms_error("I/O error during CardDAV request sending");
ms_error("[carddav] I/O error during CardDAV request sending");
linphone_carddav_query_free(query);
linphone_carddav_sync_done(query->context, FALSE, "I/O error during CardDAV request sending");
}
......@@ -412,7 +419,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
}
if (!auth_infos) {
ms_error("Authentication requested during CardDAV request sending, and username/password weren't provided");
ms_error("[carddav] Authentication requested during CardDAV request sending, and username/password weren't provided");
linphone_carddav_sync_done(query->context, FALSE, "Authentication requested during CardDAV request sending, and username/password weren't provided");
linphone_carddav_query_free(query);
}
......@@ -528,7 +535,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf)
}
if (msg) {
ms_error("%s", msg);
ms_error("[carddav] %s", msg);
}
if (cdc && cdc->sync_done_cb) {
......@@ -582,7 +589,7 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *
}
if (msg) {
ms_error("%s", msg);
ms_error("[carddav] %s", msg);
}
if (cdc && cdc->sync_done_cb) {
......
......@@ -195,6 +195,10 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
}
}
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf){
return lf->uri;
}
int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr){
LinphoneAddress *fr = linphone_address_clone(addr);
LinphoneVcard *vcard = NULL;
......@@ -211,6 +215,106 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
return 0;
}
void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
LinphoneVcard *vcard = NULL;
if (!lf || !addr) {
return;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return;
}
linphone_vcard_add_sip_address(vcard, linphone_address_as_string_uri_only(addr));
}
MSList* linphone_friend_get_addresses(LinphoneFriend *lf) {
LinphoneVcard *vcard = NULL;
MSList *sipAddresses = NULL;
MSList *addresses = NULL;
MSList *iterator = NULL;
if (!lf) {
return NULL;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return NULL;
}
sipAddresses = linphone_vcard_get_sip_addresses(vcard);
iterator = sipAddresses;
while (iterator) {
const char *sipAddress = (const char *)iterator->data;
LinphoneAddress *addr = linphone_address_new(sipAddress);
if (addr) {
addresses = ms_list_append(addresses, addr);
}
iterator = ms_list_next(iterator);
}
if (sipAddresses) ms_list_free(sipAddresses);
return addresses;
}
void linphone_friend_remove_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
LinphoneVcard *vcard = NULL;
if (!lf || !addr) {
return;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return;
}
linphone_vcard_remove_sip_address(vcard, linphone_address_as_string_uri_only(addr));
}
void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) {
LinphoneVcard *vcard = NULL;
if (!lf || !phone) {
return;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return;
}
linphone_vcard_add_phone_number(vcard, phone);
}
MSList* linphone_friend_get_phone_numbers(LinphoneFriend *lf) {
LinphoneVcard *vcard = NULL;
if (!lf) {
return NULL;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return NULL;
}
return linphone_vcard_get_phone_numbers(vcard);
}
void linphone_friend_remove_phone_number(LinphoneFriend *lf, const char *phone) {
LinphoneVcard *vcard = NULL;
if (!lf || !phone) {
return;
}
vcard = linphone_friend_get_vcard(lf);
if (!vcard) {
return;
}
linphone_vcard_remove_phone_number(vcard, phone);
}
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){
LinphoneAddress *fr = lf->uri;
LinphoneVcard *vcard = NULL;
......@@ -334,10 +438,6 @@ static belle_sip_error_code _linphone_friend_marshall(belle_sip_object_t *obj, c
return err;
}
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf){
return lf->uri;
}
const char * linphone_friend_get_name(const LinphoneFriend *lf) {
if (lf && lf->vcard) {
return linphone_vcard_get_full_name(lf->vcard);
......@@ -360,6 +460,7 @@ LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
LinphoneOnlineStatus online_status = LinphoneStatusOffline;
LinphonePresenceBasicStatus basic_status = LinphonePresenceBasicStatusClosed;
LinphonePresenceActivity *activity = NULL;
const char *description = NULL;
unsigned int nb_activities = 0;
if (lf->presence != NULL) {
......@@ -376,6 +477,7 @@ LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
}
if (nb_activities == 1) {
activity = linphone_presence_model_get_activity(lf->presence);
description = linphone_presence_activity_get_description(activity);
switch (linphone_presence_activity_get_type(activity)) {
case LinphonePresenceActivityBreakfast:
case LinphonePresenceActivityDinner:
......@@ -402,6 +504,12 @@ LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
online_status = LinphoneStatusVacation;
break;
case LinphonePresenceActivityBusy:
if (description && strcmp(description, "Do not disturb") == 0) { // See linphonecore.c linphone_core_set_presence_info() method
online_status = LinphoneStatusDoNotDisturb;
} else {
online_status = LinphoneStatusBusy;
}
break;
case LinphonePresenceActivityLookingForWork:
case LinphonePresenceActivityPlaying:
case LinphonePresenceActivityShopping:
......@@ -915,6 +1023,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) {
linphone_friend_set_address(fr, linphone_address);
linphone_address_unref(linphone_address);
}
ms_free(sipAddresses);
}
if (name) {
linphone_friend_set_name(fr, name);
......@@ -1366,7 +1475,7 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
return;
}
if (ms_list_size(linphone_friend_list_get_friends(lfl)) > 0) {
if (