Merge remote-tracking branch 'origin/master' into dev_codec_downloader

This commit is contained in:
Erwan Croze 2016-07-26 12:15:19 +02:00
commit b870bdfa9e
73 changed files with 2609 additions and 1244 deletions

View file

@ -246,7 +246,7 @@ if(MSVC)
endif()
else()
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations")
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Werror=strict-prototypes")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
endif()

2
README
View file

@ -47,7 +47,7 @@ libglew1.6-dev libv4l-dev libxml2-dev
libsqlite3-dev libupnp4-dev libsrtp-dev
+ Install zrtp (optional), for unbreakable call encryption
$ git clone git://git.linphone.org:bzrtp
$ git clone git://git.linphone.org/bzrtp.git
$ cd bzrtp && ./autogen.sh && ./configure && make
$ sudo make install

View file

@ -37,7 +37,7 @@
#include <linphonecore.h>
#include "linphonec.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#ifdef _WIN32
#include <ws2tcpip.h>

View file

@ -877,6 +877,14 @@ bool_t sal_dns_srv_enabled(const Sal *sal) {
return (bool_t)belle_sip_stack_dns_srv_enabled(sal->stack);
}
void sal_enable_dns_search(Sal *sal, bool_t enable) {
belle_sip_stack_enable_dns_search(sal->stack, (unsigned char)enable);
}
bool_t sal_dns_search_enabled(const Sal *sal) {
return (bool_t)belle_sip_stack_dns_search_enabled(sal->stack);
}
void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file) {
belle_sip_stack_set_dns_user_hosts_file(sal->stack, hosts_file);
}

View file

@ -985,7 +985,7 @@ int sal_call_send_dtmf(SalOp *h, char dtmf){
if (h->dialog && (belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_EARLY)){
belle_sip_request_t *req=belle_sip_dialog_create_queued_request(h->dialog,"INFO");
if (req){
int bodylen;
size_t bodylen;
char dtmf_body[128]={0};
snprintf(dtmf_body, sizeof(dtmf_body)-1, "Signal=%c\r\nDuration=250\r\n", dtmf);

View file

@ -115,7 +115,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
while (vCards) {
LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data;
if (vCard) {
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneFriend *lf = NULL;
bctbx_list_t *local_friend = NULL;

View file

@ -466,7 +466,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
}
linphone_chat_room_delete_composing_idle_timer(cr);
linphone_chat_room_delete_composing_refresh_timer(cr);
if (call && call->op == op) {
/*In this case, chat delivery status is not notified, so unrefing chat message right now*/
/*Might be better fixed by delivering status, but too costly for now*/
@ -475,7 +475,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
linphone_chat_message_unref(msg);
return;
}
}
// if operation failed, we should not change message state
@ -590,7 +590,7 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag
b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength);
linphone_content_set_key(
msg->file_transfer_information, (char *)keyBuffer,
keyLength); /* duplicate key value into the linphone content private structure */
strlen((char *)keyBuffer)); /* duplicate key value into the linphone content private structure */
xmlFree(keyb64);
free(keyBuffer);
}

View file

@ -49,27 +49,30 @@ static void _release_http_request(LinphoneChatMessage* msg) {
static void linphone_chat_message_process_io_error_upload(void *data, const belle_sip_io_error_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("I/O Error during file upload of msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered);
_release_http_request(msg);
linphone_chat_message_unref(msg);
}
static void linphone_chat_message_process_auth_requested_upload(void *data, belle_sip_auth_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("Error during file upload: auth requested for msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered);
_release_http_request(msg);
linphone_chat_message_unref(msg);
}
static void linphone_chat_message_process_io_error_download(void *data, const belle_sip_io_error_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("I/O Error during file download msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateFileTransferError);
_release_http_request(msg);
}
static void linphone_chat_message_process_auth_requested_download(void *data, belle_sip_auth_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
ms_error("Error during file download : auth requested for msg [%p]", msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError);
linphone_chat_message_update_state(msg, LinphoneChatMessageStateFileTransferError);
_release_http_request(msg);
}
@ -441,18 +444,38 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
int code = belle_http_response_get_status_code(event->response);
if (code == 200) {
LinphoneCore *lc = msg->chat_room->lc;
/* if the file was encrypted, finish the decryption and free context */
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0,
NULL, NULL);
}
/* file downloaded succesfully, call again the callback with size at zero */
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information,
lb);
linphone_buffer_unref(lb);
if (msg->file_transfer_filepath == NULL) {
/* if the file was encrypted, finish the decryption and free context */
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
}
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
} else {
if (linphone_content_get_key(msg->file_transfer_information) != NULL) {
bctbx_vfs_t *vfs = bctbx_vfs_get_default();
bctbx_vfs_file_t *decrypted_file;
bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r");
size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file);
char *encrypted_content = bctbx_malloc(encrypted_file_size);
char *decrypted_content = bctbx_malloc(encrypted_file_size);
bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0);
bctbx_file_close(encrypted_file);
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information),
(unsigned char *)linphone_content_get_key(msg->file_transfer_information),
encrypted_file_size, decrypted_content, encrypted_content);
lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w");
bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0);
bctbx_file_close(decrypted_file);
bctbx_free(encrypted_content);
bctbx_free(decrypted_content);
}
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
@ -557,6 +580,10 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
, msg
, msg->chat_room);
belle_http_provider_cancel_request(msg->chat_room->lc->http_provider, msg->http_request);
if (msg->dir == LinphoneChatMessageOutgoing) {
// must release it
linphone_chat_message_unref(msg);
}
} else {
ms_message("Warning: http request still running for ORPHAN msg [%p]: this is a memory leak", msg);
}

View file

@ -112,7 +112,7 @@ public:
bool microphoneIsMuted() const {return m_isMuted;}
float getInputVolume() const;
virtual int getSize() const {return m_participants.size() + (isIn()?1:0);}
virtual int getSize() const {return (int)m_participants.size() + (isIn()?1:0);}
const std::list<Participant *> &getParticipants() const {return m_participants;}
virtual int startRecording(const char *path) = 0;

View file

@ -39,12 +39,15 @@ extern "C" {
/**
* LinphoneConference class
* The _LinphoneConference struct does not exists, it's the Conference C++ class that is used behind
*/
typedef struct _LinphoneConference LinphoneConference;
/**
* Parameters for initialization of conferences
* The _LinphoneConferenceParams struct does not exists, it's the ConferenceParams C++ class that is used behind
*/
typedef struct _LinphoneCorferenceParams LinphoneConferenceParams;
typedef struct _LinphoneConferenceParams LinphoneConferenceParams;

View file

@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static char *create_enum_domain(const char *number){
size_t len=strlen(number);
long len=(long)strlen(number);
char *domain=ms_malloc((len*2)+10);
long i,j;

View file

@ -1256,7 +1256,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
LinphoneVcard *vcard = NULL;
unsigned int storage_id = (unsigned int)atoi(argv[0]);
vcard = linphone_vcard_new_from_vcard4_buffer(context, argv[6]);
vcard = linphone_vcard_context_get_vcard_from_buffer(context, argv[6]);
if (vcard) {
linphone_vcard_set_etag(vcard, argv[7]);
linphone_vcard_set_url(vcard, argv[8]);

View file

@ -781,7 +781,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
return -1;
}
vcards = linphone_vcard_list_from_vcard4_file(list->lc->vcard_context, vcard_file);
vcards = linphone_vcard_context_get_vcard_list_from_file(list->lc->vcard_context, vcard_file);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the file %s", vcard_file);
@ -820,7 +820,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
return -1;
}
vcards = linphone_vcard_list_from_vcard4_buffer(list->lc->vcard_context, vcard_buffer);
vcards = linphone_vcard_context_get_vcard_list_from_buffer(list->lc->vcard_context, vcard_buffer);
vcards_iterator = vcards;
if (!vcards) {
ms_error("Failed to parse the buffer");

View file

@ -588,7 +588,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t
lime_strToUint8(selfZid, selfZidHex, 24);
/* encrypted message length is plaintext + 16 for tag */
encryptedMessageLength = strlen((char *)message) + 16;
encryptedMessageLength = (uint32_t)strlen((char *)message) + 16;
/* retrieve keys associated to the peer URI */
associatedKeys.peerURI = (uint8_t *)malloc(strlen((char *)peerURI)+1);
@ -626,7 +626,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t
limeKey_t *currentKey = associatedKeys.peerKeys[i];
/* encrypted message include a 16 bytes tag */
uint8_t *encryptedMessage = (uint8_t *)malloc(encryptedMessageLength);
lime_encryptMessage(currentKey, message, strlen((char *)message), selfZid, encryptedMessage);
lime_encryptMessage(currentKey, message, (uint32_t)strlen((char *)message), selfZid, encryptedMessage);
/* add a "msg" node the the output message, doc node is :
* <msg>
* <pzid>peerZID</pzid>
@ -795,7 +795,7 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_
/* decrypt the message */
*output = (uint8_t *)malloc(encryptedMessageLength - 16 +1); /* plain message is same length than encrypted one with 16 bytes less for the tag + 1 to add the null termination char */
retval = lime_decryptMessage(&associatedKey, encryptedMessage, encryptedMessageLength, selfZid, *output);
retval = lime_decryptMessage(&associatedKey, encryptedMessage, (uint32_t)encryptedMessageLength, selfZid, *output);
free(encryptedMessage);

View file

@ -52,13 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifndef ANDROID /*on Android LIBLINPHONE version is passed from root Makefile*/
#include "liblinphone_gitversion.h"
#endif
#else
#ifndef LIBLINPHONE_GIT_VERSION
#define LIBLINPHONE_GIT_VERSION "unknown"
#endif
#include "liblinphone_gitversion.h"
#endif
#ifdef __APPLE__
@ -603,7 +597,7 @@ static int compress_file(FILE *input_file, COMPRESS_FILE_PTR output_file) {
total_bytes += fwrite(buffer, 1, bytes, output_file);
#endif
}
return total_bytes;
return (int)total_bytes;
}
static int prepare_log_collection_file_to_upload(const char *filename) {
@ -790,6 +784,8 @@ static void net_config_read (LinphoneCore *lc)
}
tmp = lp_config_get_int(lc->config, "net", "dns_srv_enabled", 1);
linphone_core_enable_dns_srv(lc, tmp);
tmp = lp_config_get_int(lc->config, "net", "dns_search_enabled", 1);
linphone_core_enable_dns_search(lc, tmp);
/* This is to filter out unsupported firewall policies */
if (nat_policy_ref == NULL)
@ -799,7 +795,7 @@ static void net_config_read (LinphoneCore *lc)
static void build_sound_devices_table(LinphoneCore *lc){
const char **devices;
const char **old;
int ndev;
size_t ndev;
int i;
const bctbx_list_t *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(lc->factory));
ndev=bctbx_list_size(elem);
@ -951,10 +947,7 @@ static void sip_config_read(LinphoneCore *lc)
const char *tmpstr;
LCSipTransports tr;
int i,tmp;
int ipv6_default = FALSE;
#if TARGET_OS_IPHONE
ipv6_default=TRUE;
#endif
int ipv6_default = TRUE;
if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){
sal_use_session_timers(lc->sal,200);
@ -963,13 +956,11 @@ static void sip_config_read(LinphoneCore *lc)
sal_use_no_initial_route(lc->sal,lp_config_get_int(lc->config,"sip","use_no_initial_route",0));
sal_use_rport(lc->sal,lp_config_get_int(lc->config,"sip","use_rport",1));
#if TARGET_OS_IPHONE
if (!lp_config_get_int(lc->config,"sip","ipv6_migration_done",FALSE) && lp_config_has_entry(lc->config,"sip","use_ipv6")) {
lp_config_clean_entry(lc->config,"sip","use_ipv6");
lp_config_set_int(lc->config, "sip", "ipv6_migration_done", TRUE);
ms_message("IPV6 settings migration done.");
}
#endif
lc->sip_conf.ipv6_enabled=lp_config_get_int(lc->config,"sip","use_ipv6",ipv6_default);
@ -1369,7 +1360,7 @@ static void codecs_config_read(LinphoneCore *lc){
static void build_video_devices_table(LinphoneCore *lc){
const bctbx_list_t *elem;
int i;
int ndev;
size_t ndev;
const char **devices;
if (lc->video_conf.cams)
ms_free((void *)lc->video_conf.cams);
@ -1523,6 +1514,16 @@ bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc) {
return sal_dns_srv_enabled(lc->sal);
}
void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable) {
sal_enable_dns_search(lc->sal, enable);
if (linphone_core_ready(lc))
lp_config_set_int(lc->config, "net", "dns_search_enabled", enable ? 1 : 0);
}
bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc) {
return sal_dns_search_enabled(lc->sal);
}
int linphone_core_get_download_bandwidth(const LinphoneCore *lc){
return lc->net_conf.download_bw;
}
@ -5390,7 +5391,7 @@ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) {
void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
bctbx_list_t *logs_to_migrate = NULL;
LpConfig *lpc = NULL;
int original_logs_count, migrated_logs_count;
size_t original_logs_count, migrated_logs_count;
int i;
#ifndef SQLITE_STORAGE_ENABLED
@ -5423,7 +5424,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
logs_to_migrate = lc->call_logs;
lc->call_logs = NULL;
// We can't use bctbx_list_for_each because logs_to_migrate are listed in the wrong order (latest first), and we want to store the logs latest last
for (i = bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) {
for (i = (int)bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) {
LinphoneCallLog *log = (LinphoneCallLog *) bctbx_list_nth_data(logs_to_migrate, i);
linphone_core_store_call_log(lc, log);
}
@ -5431,17 +5432,17 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
original_logs_count = bctbx_list_size(logs_to_migrate);
migrated_logs_count = bctbx_list_size(lc->call_logs);
if (original_logs_count == migrated_logs_count) {
int i = 0;
size_t i = 0;
ms_debug("call logs migration successful: %u logs migrated", (unsigned int)bctbx_list_size(lc->call_logs));
lp_config_set_int(lpc, "misc", "call_logs_migration_done", 1);
for (; i < original_logs_count; i++) {
char logsection[32];
snprintf(logsection, sizeof(logsection), "call_log_%i", i);
snprintf(logsection, sizeof(logsection), "call_log_%u", (unsigned int)i);
lp_config_clean_section(lpc, logsection);
}
} else {
ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", original_logs_count, migrated_logs_count);
ms_error("not as many logs saved in db has logs read from rc ("FORMAT_SIZE_T" in rc against "FORMAT_SIZE_T" in db)!", original_logs_count, migrated_logs_count);
}
bctbx_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref);
@ -6895,7 +6896,7 @@ void linphone_core_destroy(LinphoneCore *lc){
* @ingroup call_control
**/
int linphone_core_get_calls_nb(const LinphoneCore *lc){
return bctbx_list_size(lc->calls);;
return (int)bctbx_list_size(lc->calls);
}
/**

View file

@ -2754,6 +2754,22 @@ LINPHONE_PUBLIC void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enabl
*/
LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc);
/**
* Enable or disable DNS search (use of local domain if the fully qualified name did return results).
* @param[in] lc #LinphoneCore object.
* @param[in] enable TRUE to enable DNS search, FALSE to disable it.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable);
/**
* Tells whether DNS search (use of local domain if the fully qualified name did return results) is enabled.
* @param[in] lc #LinphoneCore object.
* @return TRUE if DNS search is enabled, FALSE if disabled.
* @ingroup media_parameters
*/
LINPHONE_PUBLIC bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc);
/**
* Forces liblinphone to use the supplied list of dns servers, instead of system's ones.
* @param[in] lc #LinphoneCore object.
@ -3464,6 +3480,12 @@ LINPHONE_PUBLIC void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc);
* @}
**/
/**
* Tells whether VCARD support is builtin.
* @return TRUE if VCARD is supported, FALSE otherwise.
* @ingroup misc
*/
LINPHONE_PUBLIC bool_t linphone_core_vcard_supported(void);
/* video support */
LINPHONE_PUBLIC bool_t linphone_core_video_supported(LinphoneCore *lc);

View file

@ -282,16 +282,19 @@ public:
chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));
friendCtrId = env->GetMethodID(friendClass,"<init>", "(J)V");
friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl"));;
friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl"));
friendListCtrId = env->GetMethodID(friendListClass,"<init>", "(J)V");
friendListCreatedId = env->GetMethodID(listenerClass, "friendListCreated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V");
friendListRemovedId = env->GetMethodID(listenerClass, "friendListRemoved", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V");
friendListSyncStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendList$State"));
friendListSyncStateFromIntId = env->GetStaticMethodID(friendListSyncStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneFriendList$State;");
natPolicyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneNatPolicyImpl"));
natPolicyCtrId = env->GetMethodID(natPolicyClass, "<init>", "(J)V");
addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
addressCtrId = env->GetMethodID(addressClass,"<init>", "(J)V");
@ -335,6 +338,7 @@ public:
env->DeleteGlobalRef(friendClass);
env->DeleteGlobalRef(friendListClass);
env->DeleteGlobalRef(friendListSyncStateClass);
env->DeleteGlobalRef(natPolicyClass);
env->DeleteGlobalRef(infoMessageClass);
env->DeleteGlobalRef(linphoneEventClass);
env->DeleteGlobalRef(subscriptionStateClass);
@ -412,6 +416,9 @@ public:
jclass friendListSyncStateClass;
jmethodID friendListSyncStateFromIntId;
jclass natPolicyClass;
jmethodID natPolicyCtrId;
jclass addressClass;
jmethodID addressCtrId;
@ -599,6 +606,29 @@ jobject getFriendList(JNIEnv *env, LinphoneFriendList *lfriendList){
return jobj;
}
jobject getNatPolicy(JNIEnv *env, LinphoneNatPolicy *lNatPolicy) {
jobject jobj = 0;
if (lNatPolicy != NULL) {
LinphoneCore *lc = lNatPolicy->lc;
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
void *up = linphone_nat_policy_get_user_data(lNatPolicy);
if (up == NULL) {
jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy);
linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj));
linphone_nat_policy_ref(lNatPolicy);
} else {
jobj = env->NewLocalRef((jobject)up);
if (jobj == NULL) {
jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy);
linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj));
}
}
}
return jobj;
}
jobject getEvent(JNIEnv *env, LinphoneEvent *lev){
if (lev==NULL) return NULL;
jobject jev=(jobject)linphone_event_get_user_data(lev);
@ -613,6 +643,29 @@ jobject getEvent(JNIEnv *env, LinphoneEvent *lev){
return jev;
}
jobject getXmlRpcRequest(JNIEnv *env, LinphoneXmlRpcRequest *lrequest) {
jobject jobj = 0;
if (lrequest != NULL) {
jclass xmlRpcSessionClass = (jclass)env->FindClass("org/linphone/core/LinphoneXmlRpcRequestImpl");
jmethodID xmlRpcSessionCtrId = env->GetMethodID(xmlRpcSessionClass, "<init>", "(J)V");
void *up = linphone_xml_rpc_request_get_user_data(lrequest);
if (up == NULL) {
jobj = env->NewObject(xmlRpcSessionClass, xmlRpcSessionCtrId, (jlong)lrequest);
linphone_xml_rpc_request_set_user_data(lrequest, (void *)env->NewWeakGlobalRef(jobj));
linphone_xml_rpc_request_ref(lrequest);
} else {
jobj = env->NewLocalRef((jobject)up);
if (jobj == NULL) {
jobj = env->NewObject(xmlRpcSessionClass, xmlRpcSessionCtrId, (jlong)lrequest);
linphone_xml_rpc_request_set_user_data(lrequest, (void *)env->NewWeakGlobalRef(jobj));
}
}
}
return jobj;
}
class LinphoneCoreData {
public:
LinphoneCoreData(JNIEnv *env, jobject lc, LinphoneCoreVTable *vTable, jobject alistener, LinphoneJavaBindings *ljb) {
@ -1431,7 +1484,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addListener(JNIEnv* env,
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeListener(JNIEnv* env, jobject thiz, jlong lc, jobject jlistener) {
MSList* iterator;
bctbx_list_t* iterator;
LinphoneCore *core = (LinphoneCore*)lc;
//jobject listener = env->NewGlobalRef(jlistener);
for (iterator = core->vtable_refs; iterator != NULL; ) {
@ -1563,12 +1616,12 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
int proxyCount = ms_list_size(proxies);
const bctbx_list_t* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
size_t proxyCount = bctbx_list_size(proxies);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc);
jobjectArray jProxies = env->NewObjectArray(proxyCount,ljb->proxyClass,NULL);
for (int i = 0; i < proxyCount; i++ ) {
for (size_t i = 0; i < proxyCount; i++ ) {
LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)proxies->data;
jobject jproxy = getProxy(env,proxy,thiz);
if(jproxy != NULL){
@ -1598,12 +1651,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeAuthInfo(JNIEnv* e
}
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getAuthInfosList(JNIEnv* env, jobject thiz,jlong lc) {
const MSList* authInfos = linphone_core_get_auth_info_list((LinphoneCore*)lc);
int listCount = ms_list_size(authInfos);
const bctbx_list_t* authInfos = linphone_core_get_auth_info_list((LinphoneCore*)lc);
size_t listCount = bctbx_list_size(authInfos);
jlongArray jAuthInfos = env->NewLongArray(listCount);
jlong *jInternalArray = env->GetLongArrayElements(jAuthInfos, NULL);
for (int i = 0; i < listCount; i++ ) {
for (size_t i = 0; i < listCount; i++ ) {
jInternalArray[i] = (unsigned long) (authInfos->data);
authInfos = authInfos->next;
}
@ -1750,12 +1803,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* en
,jobject thiz
,jlong lc
,jint position) {
return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
return (jlong)bctbx_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
,jobject thiz
,jlong lc) {
return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
return (jint)bctbx_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getLastOutgoingCallLog( JNIEnv* env
,jobject thiz
@ -1901,12 +1954,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv*
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
int codecsCount = ms_list_size(codecs);
const bctbx_list_t* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
size_t codecsCount = bctbx_list_size(codecs);
jlongArray jCodecs = env->NewLongArray(codecsCount);
jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
for (int i = 0; i < codecsCount; i++ ) {
for (size_t i = 0; i < codecsCount; i++ ) {
jInternalArray[i] = (unsigned long) (codecs->data);
codecs = codecs->next;
}
@ -1917,12 +1970,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTy
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) {
MSList *pts = NULL;
bctbx_list_t *pts = NULL;
int codecsCount = env->GetArrayLength(jCodecs);
jlong *codecs = env->GetLongArrayElements(jCodecs, NULL);
for (int i = 0; i < codecsCount; i++) {
PayloadType *pt = (PayloadType *)codecs[i];
ms_list_append(pts, pt);
bctbx_list_append(pts, pt);
}
linphone_core_set_video_codecs((LinphoneCore *)lc, pts);
env->ReleaseLongArrayElements(jCodecs, codecs, 0);
@ -1931,12 +1984,12 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoCodecs(JN
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
int codecsCount = ms_list_size(codecs);
const bctbx_list_t* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
size_t codecsCount = bctbx_list_size(codecs);
jlongArray jCodecs = env->NewLongArray(codecsCount);
jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
for (int i = 0; i < codecsCount; i++ ) {
for (size_t i = 0; i < codecsCount; i++ ) {
jInternalArray[i] = (unsigned long) (codecs->data);
codecs = codecs->next;
}
@ -1947,12 +2000,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTy
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) {
MSList *pts = NULL;
bctbx_list_t *pts = NULL;
int codecsCount = env->GetArrayLength(jCodecs);
jlong *codecs = env->GetLongArrayElements(jCodecs, NULL);
for (int i = 0; i < codecsCount; i++) {
PayloadType *pt = (PayloadType *)codecs[i];
pts = ms_list_append(pts, pt);
pts = bctbx_list_append(pts, pt);
}
linphone_core_set_audio_codecs((LinphoneCore *)lc, pts);
env->ReleaseLongArrayElements(jCodecs, codecs, 0);
@ -2137,12 +2190,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriendList(JNIEnv*
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList* friends = linphone_core_get_friend_list((LinphoneCore*)lc);
int friendsSize = ms_list_size(friends);
const bctbx_list_t* friends = linphone_core_get_friend_list((LinphoneCore*)lc);
size_t friendsSize = bctbx_list_size(friends);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc);
jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendClass,NULL);
for (int i = 0; i < friendsSize; i++) {
for (size_t i = 0; i < friendsSize; i++) {
LinphoneFriend* lfriend = (LinphoneFriend*)friends->data;
jobject jfriend = getFriend(env,lfriend);
if(jfriend != NULL){
@ -2158,12 +2211,12 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JN
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendLists(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList* friends = linphone_core_get_friends_lists((LinphoneCore*)lc);
int friendsSize = ms_list_size(friends);
const bctbx_list_t* friends = linphone_core_get_friends_lists((LinphoneCore*)lc);
size_t friendsSize = bctbx_list_size(friends);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc);
jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendListClass,NULL);
for (int i = 0; i < friendsSize; i++) {
for (size_t i = 0; i < friendsSize; i++) {
LinphoneFriendList* lfriend = (LinphoneFriendList*)friends->data;
jobject jfriend = getFriendList(env,lfriend);
if(jfriend != NULL){
@ -2251,6 +2304,11 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoSupported(JNI
return (jboolean)linphone_core_video_supported((LinphoneCore*)lc);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVCardSupported(JNIEnv* env
,jobject thiz
,jlong lc) {
return (jboolean)linphone_core_vcard_supported();
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
,jobject thiz
@ -2359,25 +2417,13 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_needsEchoCalibration(JNIEnv *env, jobject thiz, jlong lcptr) {
MSSndCard *sndcard;
LinphoneCore *lc = (LinphoneCore*) lcptr;
MSFactory * factory = linphone_core_get_ms_factory(lc);
MSSndCardManager *m = ms_factory_get_snd_card_manager(factory);
const char *card = linphone_core_get_capture_device((LinphoneCore*)lc);
sndcard = ms_snd_card_manager_get_card(m, card);
if (sndcard == NULL) {
ms_error("Could not get soundcard %s", card);
return TRUE;
}
MSDevicesInfo *devices = ms_factory_get_devices_info(factory);
SoundDeviceDescription *sound_description = ms_devices_info_get_sound_device_description(devices);
if(sound_description != NULL && sound_description == &genericSoundDeviceDescriptor){
return TRUE;
}
if (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER) return FALSE;
if (ms_snd_card_get_minimal_latency(sndcard) != 0) return FALSE;
if (sound_description == NULL) return TRUE;
if (sound_description->flags & DEVICE_HAS_BUILTIN_AEC) return FALSE;
if (sound_description->delay != 0) return FALSE;
return TRUE;
}
@ -2386,27 +2432,18 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_hasCrappyOpenGL(JNIE
MSFactory * factory = linphone_core_get_ms_factory(lc);
MSDevicesInfo *devices = ms_factory_get_devices_info(factory);
SoundDeviceDescription *sound_description = ms_devices_info_get_sound_device_description(devices);
if (sound_description != NULL && sound_description == &genericSoundDeviceDescriptor){
return FALSE;
}
if (sound_description == NULL) return FALSE;
if (sound_description->flags & DEVICE_HAS_CRAPPY_OPENGL) return TRUE;
return FALSE;
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_hasBuiltInEchoCanceler(JNIEnv *env, jobject thiz, jlong lcptr) {
MSSndCard *sndcard;
LinphoneCore *lc = (LinphoneCore*) lcptr;
MSFactory * factory = linphone_core_get_ms_factory(lc);
MSSndCardManager *m = ms_factory_get_snd_card_manager(factory);
const char *card = linphone_core_get_capture_device((LinphoneCore*)lc);
sndcard = ms_snd_card_manager_get_card(m, card);
if (sndcard == NULL) {
ms_error("Could not get soundcard %s", card);
return FALSE;
}
if (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER) return TRUE;
MSDevicesInfo *devices = ms_factory_get_devices_info(factory);
SoundDeviceDescription *sound_description = ms_devices_info_get_sound_device_description(devices);
if (sound_description == NULL) return FALSE;
if (sound_description->flags & DEVICE_HAS_BUILTIN_AEC) return TRUE;
return FALSE;
}
@ -2446,6 +2483,27 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandat
linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isLimeEncryptionAvailable (JNIEnv* env
,jobject thiz
,jlong lc
) {
return (jboolean) linphone_core_lime_available((LinphoneCore*)lc);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getLimeEncryption(JNIEnv* env
,jobject thiz
,jlong lc
) {
return (jint)linphone_core_lime_enabled((LinphoneCore*)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setLimeEncryption(JNIEnv* env
,jobject thiz
,jlong lc
,jint menc) {
linphone_core_enable_lime((LinphoneCore*)lc,(LinphoneLimeState)menc);
}
/*
* Class: org_linphone_core_LinphoneCoreImpl
* Method: disableChat
@ -3117,12 +3175,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* en
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getCallLogs(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList *logs = linphone_core_get_call_logs((LinphoneCore *) lc);
int logsCount = ms_list_size(logs);
const bctbx_list_t *logs = linphone_core_get_call_logs((LinphoneCore *) lc);
size_t logsCount = bctbx_list_size(logs);
jlongArray jLogs = env->NewLongArray(logsCount);
jlong *jInternalArray = env->GetLongArrayElements(jLogs, NULL);
for (int i = 0; i < logsCount; i++) {
for (size_t i = 0; i < logsCount; i++) {
jInternalArray[i] = (unsigned long) (logs->data);
logs = logs->next;
}
@ -3455,6 +3513,32 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setName(JNIEnv* env
ReleaseStringUTFChars(env, jname, name);
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setFamilyName(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jname) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char* name = GetStringUTFChars(env, jname);
linphone_vcard_set_family_name(lvc, name);
ReleaseStringUTFChars(env, jname, name);
}
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setGivenName(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jname) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char* name = GetStringUTFChars(env, jname);
linphone_vcard_set_given_name(lvc, name);
ReleaseStringUTFChars(env, jname, name);
}
}
extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setRLSUri(JNIEnv* env
,jobject thiz
,jlong ptr
@ -3496,13 +3580,13 @@ extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_addLocalFriend(JNI
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneFriendListImpl_getFriendList(JNIEnv* env, jobject thiz, jlong list) {
const MSList* friends = linphone_friend_list_get_friends((LinphoneFriendList *)list);
int friendsSize = ms_list_size(friends);
const bctbx_list_t* friends = linphone_friend_list_get_friends((LinphoneFriendList *)list);
size_t friendsSize = bctbx_list_size(friends);
LinphoneCore *lc = linphone_friend_list_get_core((LinphoneFriendList *)list);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendClass,NULL);
for (int i = 0; i < friendsSize; i++) {
for (size_t i = 0; i < friendsSize; i++) {
LinphoneFriend* lfriend = (LinphoneFriend*)friends->data;
jobject jfriend = getFriend(env,lfriend);
if(jfriend != NULL){
@ -3526,16 +3610,16 @@ extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_updateSubscription
extern "C" jlongArray Java_org_linphone_core_LinphoneFriendImpl_getAddresses(JNIEnv* env
,jobject thiz
,jlong ptr) {
MSList *addresses = linphone_friend_get_addresses((LinphoneFriend*)ptr);
MSList *list = addresses;
int size = ms_list_size(addresses);
bctbx_list_t *addresses = linphone_friend_get_addresses((LinphoneFriend*)ptr);
bctbx_list_t *list = addresses;
size_t size = bctbx_list_size(addresses);
jlongArray jaddresses = env->NewLongArray(size);
jlong *jInternalArray = env->GetLongArrayElements(jaddresses, NULL);
for (int i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
jInternalArray[i] = (unsigned long) (addresses->data);
addresses = ms_list_next(addresses);
addresses = bctbx_list_next(addresses);
}
ms_list_free(list);
bctbx_list_free(list);
env->ReleaseLongArrayElements(jaddresses, jInternalArray, 0);
return jaddresses;
}
@ -3557,16 +3641,16 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_removeAddress(JNIEnv*
extern "C" jobjectArray Java_org_linphone_core_LinphoneFriendImpl_getPhoneNumbers(JNIEnv* env
,jobject thiz
,jlong ptr) {
MSList *phone_numbers = linphone_friend_get_phone_numbers((LinphoneFriend*)ptr);
MSList *list = phone_numbers;
int size = ms_list_size(phone_numbers);
bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers((LinphoneFriend*)ptr);
bctbx_list_t *list = phone_numbers;
size_t size = bctbx_list_size(phone_numbers);
jobjectArray jphonenumbers = env->NewObjectArray(size, env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (int i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
const char *phone = (const char *)phone_numbers->data;
env->SetObjectArrayElement(jphonenumbers, i, env->NewStringUTF(phone));
phone_numbers = ms_list_next(phone_numbers);
phone_numbers = bctbx_list_next(phone_numbers);
}
ms_list_free(list);
bctbx_list_free(list);
return jphonenumbers;
}
@ -3605,6 +3689,30 @@ extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getName(JNIEnv* en
return name ? env->NewStringUTF(name) : NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getFamilyName(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char *name = linphone_vcard_get_family_name(lvc);
return name ? env->NewStringUTF(name) : NULL;
}
return NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getGivenName(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char *name = linphone_vcard_get_given_name(lvc);
return name ? env->NewStringUTF(name) : NULL;
}
return NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getOrganization(JNIEnv* env,
jobject thiz,
jlong ptr) {
@ -3761,15 +3869,15 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JN
}
}
extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject thiz, jlong ptr, MSList* history) {
extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject thiz, jlong ptr, bctbx_list_t* history) {
LinphoneChatRoom *room = (LinphoneChatRoom *)ptr;
LinphoneCore *lc = linphone_chat_room_get_core(room);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
MSList *list = history;
int historySize = ms_list_size(history);
bctbx_list_t *list = history;
size_t historySize = bctbx_list_size(history);
jobjectArray jHistory = env->NewObjectArray(historySize, ljb->chatMessageClass, NULL);
for (int i = 0; i < historySize; i++) {
for (size_t i = 0; i < historySize; i++) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)history->data;
jobject jmsg = getChatMessage(env, msg);
if (jmsg != NULL) {
@ -3781,7 +3889,7 @@ extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject th
}
/*getChatMessage() acquired a ref that is "transfered" to the java object. We must drop
* the reference given by linphone_chat_room_get_history_range()*/
ms_list_free_with_data(list, (void (*)(void*))linphone_chat_message_unref);
bctbx_list_free_with_data(list, (void (*)(void*))linphone_chat_message_unref);
return jHistory;
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistoryRange(JNIEnv* env
@ -3789,14 +3897,14 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistoryRa
,jlong ptr
,jint start
,jint end) {
MSList* history = linphone_chat_room_get_history_range((LinphoneChatRoom*)ptr, start, end);
bctbx_list_t* history = linphone_chat_room_get_history_range((LinphoneChatRoom*)ptr, start, end);
return _LinphoneChatRoomImpl_getHistory(env, thiz, ptr, history);
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistory(JNIEnv* env
,jobject thiz
,jlong ptr
,jint limit) {
MSList* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, limit);
bctbx_list_t* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, limit);
return _LinphoneChatRoomImpl_getHistory(env, thiz, ptr, history);
}
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
@ -4191,12 +4299,12 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getChatRooms(JNI
,jobject thiz
,jlong ptr) {
LinphoneCore *lc = (LinphoneCore*)ptr;
const MSList* chats = linphone_core_get_chat_rooms(lc);
const bctbx_list_t* chats = linphone_core_get_chat_rooms(lc);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
int chatsSize = ms_list_size(chats);
size_t chatsSize = bctbx_list_size(chats);
jobjectArray jChats = env->NewObjectArray(chatsSize, ljb->chatRoomClass, NULL);
for (int i = 0; i < chatsSize; i++) {
for (size_t i = 0; i < chatsSize; i++) {
LinphoneChatRoom *room = (LinphoneChatRoom *)chats->data;
jobject jroom = getChatRoom(env, room);
if (jroom != NULL) {
@ -4340,6 +4448,21 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv
return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
}
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createNatPolicy(JNIEnv *env, jobject thiz, jlong lc) {
LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy((LinphoneCore *)lc);
return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setNatPolicy(JNIEnv *env, jobject thiz, jlong lc, jlong jpolicy) {
linphone_core_set_nat_policy((LinphoneCore *)lc, (LinphoneNatPolicy *)jpolicy);
}
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_getNatPolicy(JNIEnv *env, jobject thiz, jlong lc) {
LinphoneNatPolicy *nat_policy = linphone_core_get_nat_policy((LinphoneCore *)lc);
return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL;
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
const char* server = GetStringUTFChars(env, jserver);
linphone_core_set_stun_server((LinphoneCore*)lc,server);
@ -4901,11 +5024,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv
linphone_core_terminate_all_calls((LinphoneCore *) pCore);
}
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
LinphoneCall* lCall = (LinphoneCall*) bctbx_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
return getCall(env,lCall);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
return (jint)bctbx_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
@ -5088,11 +5211,11 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_tunnelGetServers
jobjectArray tunnelConfigArray = NULL;
if(tunnel != NULL) {
const MSList *servers = linphone_tunnel_get_servers(tunnel);
const MSList *it;
const bctbx_list_t *servers = linphone_tunnel_get_servers(tunnel);
const bctbx_list_t *it;
int i;
tunnelConfigArray = env->NewObjectArray(ms_list_size(servers), tunnelConfigClass, NULL);
tunnelConfigArray = env->NewObjectArray(bctbx_list_size(servers), tunnelConfigClass, NULL);
for(it = servers, i=0; it != NULL; it = it->next, i++) {
LinphoneTunnelConfig *conf = (LinphoneTunnelConfig *)it->data;
jobject elt = getTunnelConfig(env, conf);
@ -7029,7 +7152,7 @@ extern "C" jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_videoMultica
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNIEnv *env, jobject thiz, jlong lc, jobjectArray servers){
MSList *l = NULL;
bctbx_list_t *l = NULL;
if (servers != NULL){
int count = env->GetArrayLength(servers);
@ -7038,13 +7161,13 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNI
jstring server = (jstring) env->GetObjectArrayElement(servers, i);
const char *str = GetStringUTFChars(env, server);
if (str){
l = ms_list_append(l, ms_strdup(str));
l = bctbx_list_append(l, ms_strdup(str));
ReleaseStringUTFChars(env, server, str);
}
}
}
linphone_core_set_dns_servers((LinphoneCore*)lc, l);
ms_list_free_with_data(l, ms_free);
bctbx_list_free_with_data(l, ms_free);
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_enableDnsSrv(JNIEnv *env, jobject thiz, jlong lc, jboolean yesno) {
@ -7365,20 +7488,20 @@ extern "C" jboolean Java_org_linphone_core_LinphoneConferenceParamsImpl_isVideoR
extern "C" jobjectArray Java_org_linphone_core_LinphoneConferenceImpl_getParticipants(JNIEnv *env, jobject thiz, jlong pconference) {
MSList *participants, *it;
bctbx_list_t *participants, *it;
jclass addr_class = env->FindClass("org/linphone/core/LinphoneAddressImpl");
jmethodID addr_constructor = env->GetMethodID(addr_class, "<init>", "(J)V");
jobjectArray jaddr_list;
int i;
participants = linphone_conference_get_participants((LinphoneConference *)pconference);
jaddr_list = env->NewObjectArray(ms_list_size(participants), addr_class, NULL);
for(it=participants, i=0; it; it=ms_list_next(it), i++) {
jaddr_list = env->NewObjectArray(bctbx_list_size(participants), addr_class, NULL);
for(it=participants, i=0; it; it=bctbx_list_next(it), i++) {
LinphoneAddress *addr = (LinphoneAddress *)it->data;
jobject jaddr = env->NewObject(addr_class, addr_constructor, (jlong)addr);
env->SetObjectArrayElement(jaddr_list, i, jaddr);
}
ms_list_free(participants);
bctbx_list_free(participants);
return jaddr_list;
}
@ -7417,3 +7540,183 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_reloadMsPlugins(J
linphone_core_reload_ms_plugins((LinphoneCore*)pcore, path);
ReleaseStringUTFChars(env, jpath, path);
}
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getCore(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneCore *lc = ((LinphoneNatPolicy *)jNatPolicy)->lc;
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
return ljb->getCore();
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_clear(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
linphone_nat_policy_clear(nat_policy);
}
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_stunEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
return (linphone_nat_policy_stun_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableStun(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
linphone_nat_policy_enable_stun(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
}
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_turnEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
return (linphone_nat_policy_turn_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableTurn(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
linphone_nat_policy_enable_turn(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
}
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_iceEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
return (linphone_nat_policy_ice_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableIce(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
linphone_nat_policy_enable_ice(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
}
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_upnpEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
return (linphone_nat_policy_upnp_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableUpnp(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
linphone_nat_policy_enable_upnp(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
}
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
const char *stun_server = linphone_nat_policy_get_stun_server(nat_policy);
return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServer) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
const char *stun_server = GetStringUTFChars(env, jStunServer);
linphone_nat_policy_set_stun_server(nat_policy, stun_server);
ReleaseStringUTFChars(env, jStunServer, stun_server);
}
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
const char *stun_server = linphone_nat_policy_get_stun_server_username(nat_policy);
return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL;
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServerUsername) {
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
const char *stun_server_username = GetStringUTFChars(env, jStunServerUsername);
linphone_nat_policy_set_stun_server_username(nat_policy, stun_server_username);
ReleaseStringUTFChars(env, jStunServerUsername, stun_server_username);
}
// XML RPC wrapper
static void xml_request_response(LinphoneXmlRpcRequest *request) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
if (result != 0) {
ms_error("cannot attach VM\n");
return;
}
LinphoneXmlRpcRequestCbs *cbs = linphone_xml_rpc_request_get_callbacks(request);
jobject listener = (jobject) linphone_xml_rpc_request_cbs_get_user_data(cbs);
if (listener == NULL) {
ms_error("xml_request_response() notification without listener");
return ;
}
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onXmlRpcRequestResponse","(Lorg/linphone/core/LinphoneXmlRpcRequest;)V");
env->DeleteLocalRef(clazz);
env->CallVoidMethod(listener, method, getXmlRpcRequest(env, request));
}
extern "C" jlong Java_org_linphone_core_LinphoneXmlRpcRequestImpl_newLinphoneXmlRpcRequest(JNIEnv *env, jobject thiz, jstring jmethodname, jint returntype) {
const char *methodname = GetStringUTFChars(env, jmethodname);
LinphoneXmlRpcRequest *request = linphone_xml_rpc_request_new(methodname, (LinphoneXmlRpcArgType)returntype);
ReleaseStringUTFChars(env, jmethodname, methodname);
return (jlong) request;
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcRequestImpl_unref(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
linphone_xml_rpc_request_set_user_data(request, NULL);
linphone_xml_rpc_request_unref(request);
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcRequestImpl_addIntArg(JNIEnv *env, jobject thiz, jlong ptr, jint arg) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
linphone_xml_rpc_request_add_int_arg(request, (int)arg);
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcRequestImpl_addStringArg(JNIEnv *env, jobject thiz, jlong ptr, jstring jarg) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
const char *arg = GetStringUTFChars(env, jarg);
linphone_xml_rpc_request_add_string_arg(request, arg);
ReleaseStringUTFChars(env, jarg, arg);
}
extern "C" jstring Java_org_linphone_core_LinphoneXmlRpcRequestImpl_getContent(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
const char *content = linphone_xml_rpc_request_get_content(request);
return content ? env->NewStringUTF(content) : NULL;
}
extern "C" jint Java_org_linphone_core_LinphoneXmlRpcRequestImpl_getStatus(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
return (jint) linphone_xml_rpc_request_get_status(request);
}
extern "C" jint Java_org_linphone_core_LinphoneXmlRpcRequestImpl_getIntResponse(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
return (jint) linphone_xml_rpc_request_get_int_response(request);
}
extern "C" jstring Java_org_linphone_core_LinphoneXmlRpcRequestImpl_getStringResponse(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
const char *response = linphone_xml_rpc_request_get_string_response(request);
return response ? env->NewStringUTF(response) : NULL;
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcRequestImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) {
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)ptr;
jobject listener = env->NewGlobalRef(jlistener);
LinphoneXmlRpcRequestCbs *cbs;
cbs = linphone_xml_rpc_request_get_callbacks(request);
linphone_xml_rpc_request_cbs_set_user_data(cbs, listener);
linphone_xml_rpc_request_cbs_set_response(cbs, xml_request_response);
}
extern "C" jlong Java_org_linphone_core_LinphoneXmlRpcSessionImpl_newLinphoneXmlRpcSession(JNIEnv *env, jobject thiz, jlong ptr, jstring jurl) {
LinphoneCore *lc = (LinphoneCore *)ptr;
const char *url = GetStringUTFChars(env, jurl);
LinphoneXmlRpcSession *session = linphone_xml_rpc_session_new(lc, url);
ReleaseStringUTFChars(env, jurl, url);
return (jlong) session;
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcSessionImpl_unref(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneXmlRpcSession *session = (LinphoneXmlRpcSession *)ptr;
linphone_xml_rpc_session_set_user_data(session, NULL);
linphone_xml_rpc_session_unref(session);
}
extern "C" void Java_org_linphone_core_LinphoneXmlRpcSessionImpl_sendRequest(JNIEnv *env, jobject thiz, jlong ptr, jlong requestPtr) {
LinphoneXmlRpcSession *session = (LinphoneXmlRpcSession *)ptr;
LinphoneXmlRpcRequest *request = (LinphoneXmlRpcRequest *)requestPtr;
linphone_xml_rpc_session_send_request(session, request);
}

View file

@ -25,7 +25,7 @@
#define MAX_LEN 16384
#include "linphonecore.h"
#include "bctoolbox/bc_vfs.h"
#include "bctoolbox/vfs.h"
#include <stdio.h>
#include <stdlib.h>
@ -397,10 +397,6 @@ LpConfig * lp_config_new_from_buffer(const char *buffer){
}
LpConfig *lp_config_new_with_factory(const char *config_filename, const char *factory_config_filename) {
int fd;
bctbx_vfs_file_t* pFile = NULL;
LpConfig *lpconfig=lp_new0(LpConfig,1);
lpconfig->g_bctbx_vfs = bctbx_vfs_get_default();
@ -430,23 +426,20 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa
}
}
#endif /*_WIN32*/
/*open with r+ to check if we can write on it later*/
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->filename, "r+");
fd = pFile->fd;
lpconfig->pFile = pFile;
/*open with r+ to check if we can write on it later*/
lpconfig->pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->filename, "r+");
#ifdef RENAME_REQUIRES_NONEXISTENT_NEW_PATH
if (fd == -1){
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+");
if (fd){
if (lpconfig->pFile == NULL){
lpconfig->pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+");
if (lpconfig->pFile == NULL){
ms_warning("Could not open %s but %s works, app may have crashed during last sync.",lpconfig->filename,lpconfig->tmpfilename);
}
}
#endif
if (fd != -1){
lp_config_parse(lpconfig, pFile);
bctbx_file_close(pFile);
if (lpconfig->pFile != NULL){
lp_config_parse(lpconfig, lpconfig->pFile);
bctbx_file_close(lpconfig->pFile);
lpconfig->pFile = NULL;
lpconfig->modified=0;
}
@ -463,10 +456,8 @@ fail:
int lp_config_read_file(LpConfig *lpconfig, const char *filename){
char* path = lp_realpath(filename, NULL);
int fd=-1;
bctbx_vfs_file_t* pFile = bctbx_file_open(lpconfig->g_bctbx_vfs, path, "r");
fd = pFile->fd;
if (fd != -1){
if (pFile != NULL){
ms_message("Reading config information from %s", path);
lp_config_parse(lpconfig, pFile);
bctbx_file_close(pFile);
@ -927,7 +918,7 @@ static const char *_lp_config_dirname(char *path) {
}
bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *filename) {
bctbx_vfs_file_t *pFile = lpconfig->pFile;
bctbx_vfs_file_t *pFile;
if (lpconfig->filename == NULL) {
return FALSE;
} else {
@ -943,10 +934,10 @@ bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *file
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "r");
ms_free(realfilepath);
if (pFile->fd != -1) {
if (pFile != NULL) {
bctbx_file_close(pFile);
}
return pFile->fd > 0;
return pFile != NULL;
}
}
@ -955,9 +946,8 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
const char *dir = NULL;
char *filepath = NULL;
char *realfilepath = NULL;
int fd = 0;
bctbx_vfs_file_t *pFile;
bctbx_vfs_file_t *pFile = lpconfig->pFile;
if (lpconfig->filename == NULL) return;
if(strlen(data) == 0) {
@ -974,10 +964,8 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
goto end;
}
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "w");
fd = pFile->fd;
if(fd == -1) {
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath, "w");
if(pFile == NULL) {
ms_error("Could not open %s for write", realfilepath);
goto end;
}
@ -994,7 +982,6 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename,
char *dup_config_file = NULL;
const char *dir = NULL;
char *filepath = NULL;
int fd = 0;
bctbx_vfs_file_t* pFile = NULL;
char* realfilepath = NULL;
@ -1011,16 +998,12 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename,
}
pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,realfilepath,"r");
if (pFile !=NULL)
fd = pFile->fd;
if(fd == -1 ) {
if (pFile == NULL) {
ms_error("Could not open %s for read.", realfilepath);
goto err;
}
if(bctbx_file_read(pFile, data, 1, max_length) < 0){
if(bctbx_file_read(pFile, data, 1, (off_t)max_length) < 0){
ms_error("%s could not be loaded.", realfilepath);
goto err;
@ -1043,7 +1026,7 @@ err:
const char** lp_config_get_sections_names(LpConfig *lpconfig) {
const char **sections_names;
const bctbx_list_t *sections = lpconfig->sections;
int ndev;
size_t ndev;
int i;
ndev = bctbx_list_size(sections);

View file

@ -85,7 +85,7 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) {
* We workaround by asking that the open is made with no protection*/
flags |= SQLITE_OPEN_FILEPROTECTION_NONE;
#endif
/*since we plug our vfs into sqlite, we convert to UTF-8.
* On Windows, the filename has to be converted back to windows native charset.*/
char *utf8_filename = utf8_convert(db_file);
@ -138,8 +138,8 @@ static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom*
* | 4 | encoding
* | 5 | size
* | 6 | data (currently not stored)
* | 7 | size
* | 8 | size
* | 7 | key size
* | 8 | key
*/
// Callback for sql request when getting linphone content
static int callback_content(void *data, int argc, char **argv, char **colName) {
@ -209,16 +209,15 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName
// check if the message exists in the transient list, in which case we should return that one.
LinphoneChatMessage* new_message = get_transient_message(cr, storage_id);
if( new_message == NULL ){
LinphoneAddress *local_addr=linphone_address_new(argv[1]);
new_message = linphone_chat_room_create_message(cr, argv[4]);
if(atoi(argv[3])==LinphoneChatMessageIncoming){
new_message->dir=LinphoneChatMessageIncoming;
linphone_chat_message_set_from(new_message,linphone_chat_room_get_peer_address(cr));
new_message->to = local_addr; /*direct assignation to avoid a copy*/
new_message->to = NULL; /*will be filled at the end */
} else {
new_message->dir=LinphoneChatMessageOutgoing;
new_message->from = local_addr; /*direct assignation to avoid a copy*/
new_message->from = NULL; /*will be filled at the end */
linphone_chat_message_set_to(new_message,linphone_chat_room_get_peer_address(cr));
}
@ -491,16 +490,33 @@ bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int sta
ms_free(buf);
buf = buf2;
}
begin=ortp_get_cur_time_ms();
linphone_sql_request_message(lc->db,buf,cr);
end=ortp_get_cur_time_ms();
if (endm+1-startm > 1) {
//display message only if at least 2 messages are loaded
ms_message("%s(): completed in %i ms",__FUNCTION__, (int)(end-begin));
}
ms_free(buf);
if (cr->messages_hist) {
//fill local addr with core identity instead of per message
LinphoneAddress* local_addr = linphone_address_new(linphone_core_get_identity(cr->lc));
bctbx_list_t* it = cr->messages_hist;
while (it) {
LinphoneChatMessage* msg = it->data;
if (msg->dir == LinphoneChatMessageOutgoing) {
msg->from = linphone_address_ref(local_addr);
} else {
msg->to = linphone_address_ref(local_addr);
}
it = it->next;
}
linphone_address_unref(local_addr);
}
ret=cr->messages_hist;
cr->messages_hist=NULL;
ms_free(peer);
@ -650,7 +666,7 @@ void linphone_update_table(sqlite3* db) {
ms_debug("Table content successfully created.");
}
}
// new fields for content key storage when using lime
ret=sqlite3_exec(db,"ALTER TABLE content ADD COLUMN key_size INTEGER;",NULL,NULL,&errmsg);
if(ret != SQLITE_OK) {

View file

@ -319,7 +319,7 @@ static ortp_socket_t create_socket(int local_port){
static int send_stun_request(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t change_addr){
char *buf = NULL;
int len;
size_t len;
int err = 0;
MSStunMessage *req = ms_stun_binding_request_create();
UInt96 tr_id = ms_stun_message_get_tr_id(req);
@ -332,7 +332,7 @@ static int send_stun_request(int sock, const struct sockaddr *server, socklen_t
ms_error("Fail to encode stun message.");
err = -1;
} else {
err = sendto(sock, buf, len, 0, server, addrlen);
err = bctbx_sendto(sock, buf, len, 0, server, addrlen);
if (err < 0) {
ms_error("sendto failed: %s",strerror(errno));
err = -1;
@ -587,16 +587,17 @@ void linphone_core_resolve_stun_server(LinphoneCore *lc){
if (lc->nat_policy != NULL) {
linphone_nat_policy_resolve_stun_server(lc->nat_policy);
} else {
/*
* WARNING: stun server resolution only done in IPv4.
* TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering.
*/
const char *server=linphone_core_get_stun_server(lc);
if (lc->sal && server && !lc->net_conf.stun_res){
LinphoneFirewallPolicy firewall_policy = linphone_core_get_firewall_policy(lc);
if (lc->sal && server && !lc->net_conf.stun_res
&& ((firewall_policy == LinphonePolicyUseStun) || (firewall_policy == LinphonePolicyUseIce))) {
char host[NI_MAXHOST];
const char *service = "stun";
int port=3478;
int family = AF_INET;
linphone_parse_host_port(server,host,sizeof(host),&port);
lc->net_conf.stun_res=sal_resolve_a(lc->sal,host,port,AF_INET,(SalResolverCallback)stun_server_resolved,lc);
if (linphone_core_ipv6_enabled(lc) == TRUE) family = AF_INET6;
lc->net_conf.stun_res = sal_resolve(lc->sal, service, "udp", host, port, family, (SalResolverCallback)stun_server_resolved, lc);
}
}
}
@ -682,12 +683,55 @@ static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const
}
}
static void linphone_core_add_local_ice_candidates(LinphoneCall *call, int family, const char *addr, IceCheckList *audio_cl, IceCheckList *video_cl, IceCheckList *text_cl) {
if ((ice_check_list_state(audio_cl) != ICL_Completed) && (ice_check_list_candidates_gathered(audio_cl) == FALSE)) {
ice_add_local_candidate(audio_cl, "host", family, addr, call->media_ports[call->main_audio_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(audio_cl, "host", family, addr, call->media_ports[call->main_audio_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress;
}
if (linphone_core_video_enabled(call->core) && (video_cl != NULL)
&& (ice_check_list_state(video_cl) != ICL_Completed) && (ice_check_list_candidates_gathered(video_cl) == FALSE)) {
ice_add_local_candidate(video_cl, "host", family, addr, call->media_ports[call->main_video_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(video_cl, "host", family, addr, call->media_ports[call->main_video_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress;
}
if (call->params->realtimetext_enabled && (text_cl != NULL)
&& (ice_check_list_state(text_cl) != ICL_Completed) && (ice_check_list_candidates_gathered(text_cl) == FALSE)) {
ice_add_local_candidate(text_cl, "host", family, addr, call->media_ports[call->main_text_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(text_cl, "host", family, addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_TEXT].ice_state = LinphoneIceStateInProgress;
}
}
static const struct addrinfo * get_preferred_stun_server_addrinfo(const struct addrinfo *ai) {
char ip[NI_MAXHOST];
const struct addrinfo *preferred_ai = NULL;
while (ai != NULL) {
bctbx_addrinfo_to_printable_ip_address(ai, ip, sizeof(ip));
if (ai->ai_family == AF_INET) {
preferred_ai = ai;
break;
}
else if (ai->ai_family == AF_INET6) {
struct sockaddr_storage ss;
socklen_t sslen = sizeof(ss);
bctbx_sockaddr_ipv6_to_ipv4(ai->ai_addr, (struct sockaddr *)&ss, &sslen);
if ((ss.ss_family == AF_INET) && (preferred_ai == NULL)) preferred_ai = ai;
}
ai = ai->ai_next;
}
bctbx_addrinfo_to_printable_ip_address(preferred_ai, ip, sizeof(ip));
return preferred_ai;
}
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
char local_addr[64];
const struct addrinfo *ai = NULL;
IceCheckList *audio_check_list;
IceCheckList *video_check_list;
IceCheckList *text_check_list;
IceCheckList *audio_cl;
IceCheckList *video_cl;
IceCheckList *text_cl;
LinphoneNatPolicy *nat_policy = NULL;
const char *server = NULL;
@ -696,19 +740,17 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
if (nat_policy != NULL) server = linphone_nat_policy_get_stun_server(nat_policy);
if (call->ice_session == NULL) return -1;
audio_check_list = ice_session_check_list(call->ice_session, call->main_audio_stream_index);
video_check_list = ice_session_check_list(call->ice_session, call->main_video_stream_index);
text_check_list = ice_session_check_list(call->ice_session, call->main_text_stream_index);
if (audio_check_list == NULL) return -1;
audio_cl = ice_session_check_list(call->ice_session, call->main_audio_stream_index);
video_cl = ice_session_check_list(call->ice_session, call->main_video_stream_index);
text_cl = ice_session_check_list(call->ice_session, call->main_text_stream_index);
if (audio_cl == NULL) return -1;
if (call->af==AF_INET6){
ms_warning("Ice gathering is not implemented for ipv6");
return -1;
}
if ((nat_policy != NULL) && (server != NULL) && (server[0] != '\0')) {
ai=linphone_nat_policy_get_stun_server_addrinfo(nat_policy);
if (ai==NULL){
ms_warning("Fail to resolve STUN server for ICE gathering, continuing without stun.");
} else {
ai = get_preferred_stun_server_addrinfo(ai);
}
}else{
ms_warning("Ice is used without stun server.");
@ -718,28 +760,22 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
ice_session_enable_forced_relay(call->ice_session, lc->forced_ice_relay);
ice_session_enable_short_turn_refresh(call->ice_session, lc->short_turn_refresh);
// TODO: Handle IPv6
/* Gather local host candidates. */
if (call->af == AF_INET6) {
if (linphone_core_get_local_ip_for(AF_INET6, NULL, local_addr) < 0) {
ms_error("Fail to get local IPv6");
return -1;
} else {
linphone_core_add_local_ice_candidates(call, AF_INET6, local_addr, audio_cl, video_cl, text_cl);
}
}
if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) {
ms_error("Fail to get local ip");
return -1;
}
if ((ice_check_list_state(audio_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(audio_check_list) == FALSE)) {
ice_add_local_candidate(audio_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_audio_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(audio_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_audio_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress;
}
if (linphone_core_video_enabled(lc) && (video_check_list != NULL)
&& (ice_check_list_state(video_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(video_check_list) == FALSE)) {
ice_add_local_candidate(video_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_video_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(video_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_video_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress;
}
if (call->params->realtimetext_enabled && (text_check_list != NULL)
&& (ice_check_list_state(text_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(text_check_list) == FALSE)) {
ice_add_local_candidate(text_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_text_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(text_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_TEXT].ice_state = LinphoneIceStateInProgress;
if (call->af != AF_INET6) {
ms_error("Fail to get local IPv4");
return -1;
}
} else {
linphone_core_add_local_ice_candidates(call, AF_INET, local_addr, audio_cl, video_cl, text_cl);
}
if ((ai != NULL) && (nat_policy != NULL)
&& (linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) {
@ -905,7 +941,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess
IceSessionState session_state = ice_session_state(session);
int nb_candidates;
int i;
size_t j;
int j;
bool_t result;
if (session_state == IS_Completed) {
@ -955,7 +991,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess
stream->ice_mismatch = ice_check_list_is_mismatch(cl);
if ((ice_check_list_state(cl) == ICL_Running) || (ice_check_list_state(cl) == ICL_Completed)) {
memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates));
for (j = 0; j < MIN(bctbx_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) {
for (j = 0; j < MIN((int)bctbx_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) {
SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates];
IceCandidate *ice_candidate = bctbx_list_nth_data(cl->local_candidates, j);
const char *default_addr = NULL;
@ -1123,6 +1159,7 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call,
ice_session_remove_check_list(call->ice_session, cl);
clear_ice_check_list(call,cl);
} else {
int family;
if ((stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0'))
ice_check_list_set_remote_credentials(cl, stream->ice_ufrag, stream->ice_pwd);
for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES; j++) {
@ -1135,8 +1172,9 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call,
get_default_addr_and_port(candidate->componentID, md, stream, &addr, &port);
if (addr && (candidate->port == port) && (strlen(candidate->addr) == strlen(addr)) && (strcmp(candidate->addr, addr) == 0))
default_candidate = TRUE;
// TODO: Handle IPv6
ice_add_remote_candidate(cl, candidate->type, AF_INET, candidate->addr, candidate->port, candidate->componentID,
if (strchr(candidate->addr, ':') != NULL) family = AF_INET6;
else family = AF_INET;
ice_add_remote_candidate(cl, candidate->type, family, candidate->addr, candidate->port, candidate->componentID,
candidate->priority, candidate->foundation, default_candidate);
}
if (ice_restarted == FALSE) {
@ -1152,8 +1190,9 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call,
/* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */
ice_check_list_unselect_valid_pairs(cl);
}
// TODO: Handle IPv6
ice_add_losing_pair(cl, j + 1, AF_INET, remote_candidate->addr, remote_candidate->port, addr, port);
if (strchr(remote_candidate->addr, ':') != NULL) family = AF_INET6;
else family = AF_INET;
ice_add_losing_pair(cl, j + 1, family, remote_candidate->addr, remote_candidate->port, addr, port);
losing_pairs_added = TRUE;
}
if (losing_pairs_added == TRUE) ice_check_list_check_completed(cl);
@ -1748,8 +1787,9 @@ void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *aud
}
const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){
const char *config=lp_config_get_string(lc->config,"sip","srtp_crypto_suites","AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_CM_256_HMAC_SHA1_80, AES_CM_256_HMAC_SHA1_32");
const char *config= lp_config_get_string(lc->config, "sip", "srtp_crypto_suites", "AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_256_CM_HMAC_SHA1_80, AES_256_CM_HMAC_SHA1_32");
char *tmp=ms_strdup(config);
char *sep;
char *pos;
char *nextpos;

View file

@ -220,20 +220,16 @@ static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, st
void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy) {
const char *service = NULL;
/*
* WARNING: stun server resolution only done in IPv4.
* TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering.
*/
if (linphone_nat_policy_stun_server_activated(policy)
&& (policy->lc->sal != NULL)
&& !policy->stun_resolver_context) {
if (linphone_nat_policy_stun_server_activated(policy) && (policy->lc->sal != NULL) && !policy->stun_resolver_context) {
char host[NI_MAXHOST];
int port = 3478;
linphone_parse_host_port(policy->stun_server, host, sizeof(host), &port);
if (linphone_nat_policy_turn_enabled(policy)) service = "turn";
else if (linphone_nat_policy_stun_enabled(policy)) service = "stun";
if (service != NULL) {
policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, AF_INET, (SalResolverCallback)stun_server_resolved, policy);
int family = AF_INET;
if (linphone_core_ipv6_enabled(policy->lc) == TRUE) family = AF_INET6;
policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, family, (SalResolverCallback)stun_server_resolved, policy);
}
}
}

View file

@ -156,7 +156,7 @@ LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *poli
LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy);
/**
* Seth the username used to authenticate with the STUN/TURN server.
* Set the username used to authenticate with the STUN/TURN server.
* The authentication will search for a LinphoneAuthInfo with this username.
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
* @param[in] policy LinphoneNatPolicy object

View file

@ -360,7 +360,7 @@ int linphone_presence_model_set_contact(LinphonePresenceModel *model, const char
}
static void presence_model_count_activities(const LinphonePresencePerson *person, unsigned int *nb) {
*nb += bctbx_list_size(person->activities);
*nb += (unsigned int)bctbx_list_size(person->activities);
}
struct _get_activity_st {
@ -371,7 +371,7 @@ struct _get_activity_st {
static void presence_model_get_activity(const LinphonePresencePerson *person, struct _get_activity_st *st) {
if (st->current_idx != (unsigned)-1) {
unsigned int size = bctbx_list_size(person->activities);
unsigned int size = (unsigned int)bctbx_list_size(person->activities);
if (st->requested_idx < (st->current_idx + size)) {
st->activity = (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, st->requested_idx - st->current_idx);
st->current_idx = (unsigned)-1;
@ -471,10 +471,8 @@ struct _find_note_st {
};
static LinphonePresenceNote * find_presence_note_in_list(bctbx_list_t *list, const char *lang) {
int nb;
int i;
nb = bctbx_list_size(list);
int nb = (int)bctbx_list_size(list);
for (i = 0; i < nb; i++) {
LinphonePresenceNote *note = (LinphonePresenceNote *)bctbx_list_nth_data(list, i);
if (lang == NULL) {
@ -632,7 +630,7 @@ LinphonePresenceModel * linphone_presence_model_new(void) {
}
unsigned int linphone_presence_model_get_nb_services(const LinphonePresenceModel *model) {
return bctbx_list_size(model->services);
return (unsigned int)bctbx_list_size(model->services);
}
LinphonePresenceService * linphone_presence_model_get_nth_service(const LinphonePresenceModel *model, unsigned int idx) {
@ -658,7 +656,7 @@ int linphone_presence_model_clear_services(LinphonePresenceModel *model) {
}
unsigned int linphone_presence_model_get_nb_persons(const LinphonePresenceModel *model) {
return bctbx_list_size(model->persons);
return (unsigned int)bctbx_list_size(model->persons);
}
LinphonePresencePerson * linphone_presence_model_get_nth_person(const LinphonePresenceModel *model, unsigned int idx) {
@ -762,7 +760,7 @@ int linphone_presence_service_set_contact(LinphonePresenceService *service, cons
}
unsigned int linphone_presence_service_get_nb_notes(const LinphonePresenceService *service) {
return bctbx_list_size(service->notes);
return (unsigned int)bctbx_list_size(service->notes);
}
LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx) {
@ -815,7 +813,7 @@ int linphone_presence_person_set_id(LinphonePresencePerson *person, const char *
unsigned int linphone_presence_person_get_nb_activities(const LinphonePresencePerson *person) {
if (person == NULL) return 0;
return bctbx_list_size(person->activities);
return (unsigned int)bctbx_list_size(person->activities);
}
LinphonePresenceActivity * linphone_presence_person_get_nth_activity(const LinphonePresencePerson *person, unsigned int idx) {
@ -841,7 +839,7 @@ int linphone_presence_person_clear_activities(LinphonePresencePerson *person) {
unsigned int linphone_presence_person_get_nb_notes(const LinphonePresencePerson *person) {
if (person == NULL) return 0;
return bctbx_list_size(person->notes);
return (unsigned int)bctbx_list_size(person->notes);
}
LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx) {
@ -866,7 +864,7 @@ int linphone_presence_person_clear_notes(LinphonePresencePerson *person) {
unsigned int linphone_presence_person_get_nb_activities_notes(const LinphonePresencePerson *person) {
if (person == NULL) return 0;
return bctbx_list_size(person->activities_notes);
return (unsigned int)bctbx_list_size(person->activities_notes);
}
LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx) {

View file

@ -38,7 +38,7 @@
#include "vcard.h"
#include <bctoolbox/port.h>
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#include <belle-sip/object.h>
#include <belle-sip/dict.h>
@ -1555,11 +1555,6 @@ char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ;
void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite);
LinphoneVcardContext* linphone_vcard_context_new(void);
void linphone_vcard_context_destroy(LinphoneVcardContext *context);
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context);
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data);
#ifdef __cplusplus
}
#endif

View file

@ -853,12 +853,13 @@ const char* sal_privacy_to_string(SalPrivacy privacy) {
}
}
static void remove_trailing_spaces(char *line){
int i;
for(i=strlen(line)-1;i>=0;--i){
if (isspace(line[i])) line[i]='\0';
else break;
static void remove_trailing_spaces(char *line) {
size_t size = size = strlen(line);
char *end = line + size - 1;
while (end >= line && isspace(*end)) {
end--;
}
*(end + 1) = '\0';
}
static int line_get_value(const char *input, const char *key, char *value, size_t value_size, size_t *read){

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
#include <fcntl.h>
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#include "sqlite3.h"

View file

@ -1,357 +1,409 @@
/*
vcard.cc
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "vcard.h"
#include "belcard/belcard.hpp"
#include "belcard/belcard_parser.hpp"
#include "sal/sal.h"
#include <bctoolbox/crypto.h>
struct _LinphoneVcardContext {
belcard::BelCardParser *parser;
void *user_data;
};
struct _LinphoneVcard {
shared_ptr<belcard::BelCard> belCard;
char *etag;
char *url;
unsigned char *md5;
};
#ifdef __cplusplus
extern "C" {
#endif
LinphoneVcardContext* linphone_vcard_context_new(void) {
LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1);
context->parser = new belcard::BelCardParser();
context->user_data = NULL;
return context;
}
void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
if (context) {
if (context->parser) delete context->parser;
ms_free(context);
}
}
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) {
if (context) context->user_data = data;
}
LinphoneVcard* linphone_vcard_new(void) {
LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1);
vCard->belCard = belcard::BelCardGeneric::create<belcard::BelCard>();
return vCard;
}
static LinphoneVcard* linphone_vcard_new_from_belcard(shared_ptr<belcard::BelCard> belcard) {
LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1);
vCard->belCard = belcard;
return vCard;
}
void linphone_vcard_free(LinphoneVcard *vCard) {
if (!vCard) return;
if (vCard->etag) ms_free(vCard->etag);
if (vCard->url) ms_free(vCard->url);
vCard->belCard.reset();
ms_free(vCard);
}
bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) {
bctbx_list_t *result = NULL;
if (context && filename) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCardList> belCards = parser->parseFile(filename);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
}
}
return result;
}
bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
bctbx_list_t *result = NULL;
if (context && buffer) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCardList> belCards = parser->parse(buffer);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
}
}
return result;
}
LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
LinphoneVcard *vCard = NULL;
if (context && buffer) {
belcard::BelCardParser *parser = context->parser;
shared_ptr<belcard::BelCard> belCard = parser->parseOne(buffer);
if (belCard) {
vCard = linphone_vcard_new_from_belcard(belCard);
} else {
ms_error("Couldn't parse buffer %s", buffer);
}
}
return vCard;
}
const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->belCard->toFoldedString().c_str();
}
void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
shared_ptr<belcard::BelCardFullName> fn = belcard::BelCardGeneric::create<belcard::BelCardFullName>();
fn->setValue(name);
vCard->belCard->setFullName(fn);
}
const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getFullName() ? vCard->belCard->getFullName()->getValue().c_str() : NULL;
return result;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard || !sip_address) return;
shared_ptr<belcard::BelCardImpp> impp = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
impp->setValue(sip_address);
vCard->belCard->addImpp(impp);
}
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard) return;
shared_ptr<belcard::BelCardImpp> impp;
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strcmp(value, sip_address) == 0) {
impp = *it;
break;
}
}
if (impp) {
vCard->belCard->removeImpp(impp);
}
}
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard || !sip_address) return;
if (vCard->belCard->getImpp().size() > 0) {
const shared_ptr<belcard::BelCardImpp> impp = vCard->belCard->getImpp().front();
impp->setValue(sip_address);
} else {
shared_ptr<belcard::BelCardImpp> impp = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
impp->setValue(sip_address);
vCard->belCard->addImpp(impp);
}
}
bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
bctbx_list_t *result = NULL;
if (!vCard) return NULL;
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strncmp(value, "sip:", 4) == 0) {
result = bctbx_list_append(result, (char *)value);
}
}
return result;
}
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
if (!vCard || !phone) return;
shared_ptr<belcard::BelCardPhoneNumber> phone_number = belcard::BelCardGeneric::create<belcard::BelCardPhoneNumber>();
phone_number->setValue(phone);
vCard->belCard->addPhoneNumber(phone_number);
}
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
if (!vCard) return;
shared_ptr<belcard::BelCardPhoneNumber> tel;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strcmp(value, phone) == 0) {
tel = *it;
break;
}
}
if (tel) {
vCard->belCard->removePhoneNumber(tel);
}
}
bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
bctbx_list_t *result = NULL;
if (!vCard) return NULL;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
const char *value = (*it)->getValue().c_str();
result = bctbx_list_append(result, (char *)value);
}
return result;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
if (!vCard) return;
if (vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
org->setValue(organization);
} else {
shared_ptr<belcard::BelCardOrganization> org = belcard::BelCardGeneric::create<belcard::BelCardOrganization>();
org->setValue(organization);
vCard->belCard->addOrganization(org);
}
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
if (vCard && vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
return org->getValue().c_str();
}
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
char uuid[64];
if (vCard) {
if (linphone_vcard_get_uid(vCard)) {
return FALSE;
}
if (sal_generate_uuid(uuid, sizeof(uuid)) == 0) {
char vcard_uuid[sizeof(uuid)+4];
snprintf(vcard_uuid, sizeof(vcard_uuid), "urn:%s", uuid);
linphone_vcard_set_uid(vCard, vcard_uuid);
return TRUE;
}
}
return FALSE;
}
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) {
if (!vCard || !uid) return;
shared_ptr<belcard::BelCardUniqueId> uniqueId = belcard::BelCardGeneric::create<belcard::BelCardUniqueId>();
uniqueId->setValue(uid);
vCard->belCard->setUniqueId(uniqueId);
}
const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) {
if (vCard && vCard->belCard->getUniqueId()) {
return vCard->belCard->getUniqueId()->getValue().c_str();
}
return NULL;
}
void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) {
if (!vCard) {
return;
}
if (vCard->etag) {
ms_free(vCard->etag);
vCard->etag = NULL;
}
vCard->etag = ms_strdup(etag);
}
const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->etag;
}
void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) {
if (!vCard) {
return;
}
if (vCard->url) {
ms_free(vCard->url);
vCard->url = NULL;
}
vCard->url = ms_strdup(url);
}
const char* linphone_vcard_get_url(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->url;
}
#define VCARD_MD5_HASH_SIZE 16
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) {
unsigned char digest[VCARD_MD5_HASH_SIZE];
const char *text = NULL;
if (!vCard) {
return;
}
text = linphone_vcard_as_vcard4_string(vCard);
bctbx_md5((unsigned char *)text, strlen(text), digest);
vCard->md5 = (unsigned char *)ms_malloc(sizeof(digest));
memcpy(vCard->md5, digest, sizeof(digest));
}
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) {
unsigned char *previous_md5 = vCard->md5;
unsigned char *new_md5 = NULL;
int result = -1;
if (!previous_md5) {
return result;
}
linphone_vcard_compute_md5_hash(vCard);
new_md5 = vCard->md5;
result = memcmp(new_md5, previous_md5, VCARD_MD5_HASH_SIZE);
ms_free(previous_md5);
ms_free(new_md5);
return result;
}
#ifdef __cplusplus
}
#endif
/*
vcard.cc
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "vcard.h"
#include "belcard/belcard.hpp"
#include "belcard/belcard_parser.hpp"
#include "sal/sal.h"
#include <bctoolbox/crypto.h>
struct _LinphoneVcardContext {
belcard::BelCardParser *parser;
void *user_data;
};
struct _LinphoneVcard {
shared_ptr<belcard::BelCard> belCard;
char *etag;
char *url;
unsigned char *md5;
};
#ifdef __cplusplus
extern "C" {
#endif
LinphoneVcardContext* linphone_vcard_context_new(void) {
LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1);
context->parser = new belcard::BelCardParser();
context->user_data = NULL;
return context;
}
void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
if (context) {
if (context->parser) delete context->parser;
ms_free(context);
}
}
void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) {
if (context) context->user_data = data;
}
LinphoneVcard* linphone_vcard_new(void) {
LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1);
vCard->belCard = belcard::BelCardGeneric::create<belcard::BelCard>();
return vCard;
}
static LinphoneVcard* linphone_vcard_new_from_belcard(shared_ptr<belcard::BelCard> belcard) {
LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1);
vCard->belCard = belcard;
return vCard;
}
void linphone_vcard_free(LinphoneVcard *vCard) {
if (!vCard) return;
if (vCard->etag) ms_free(vCard->etag);
if (vCard->url) ms_free(vCard->url);
vCard->belCard.reset();
ms_free(vCard);
}
bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) {
bctbx_list_t *result = NULL;
if (context && filename) {
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
}
}
return result;
}
bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) {
bctbx_list_t *result = NULL;
if (context && buffer) {
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer);
if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it);
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
}
}
return result;
}
LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) {
LinphoneVcard *vCard = NULL;
if (context && buffer) {
if (!context->parser) {
context->parser = new belcard::BelCardParser();
}
shared_ptr<belcard::BelCard> belCard = context->parser->parseOne(buffer);
if (belCard) {
vCard = linphone_vcard_new_from_belcard(belCard);
} else {
ms_error("Couldn't parse buffer %s", buffer);
}
}
return vCard;
}
const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->belCard->toFoldedString().c_str();
}
void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
if (vCard->belCard->getFullName()) {
vCard->belCard->getFullName()->setValue(name);
} else {
shared_ptr<belcard::BelCardFullName> fn = belcard::BelCardGeneric::create<belcard::BelCardFullName>();
fn->setValue(name);
vCard->belCard->setFullName(fn);
}
}
const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getFullName() ? vCard->belCard->getFullName()->getValue().c_str() : NULL;
return result;
}
void linphone_vcard_set_family_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
if (vCard->belCard->getName()) {
vCard->belCard->getName()->setFamilyName(name);
} else {
shared_ptr<belcard::BelCardName> n = belcard::BelCardGeneric::create<belcard::BelCardName>();
n->setFamilyName(name);
vCard->belCard->setName(n);
}
}
const char* linphone_vcard_get_family_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getName() ? vCard->belCard->getName()->getFamilyName().c_str() : NULL;
return result;
}
void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
if (vCard->belCard->getName()) {
vCard->belCard->getName()->setGivenName(name);
} else {
shared_ptr<belcard::BelCardName> n = belcard::BelCardGeneric::create<belcard::BelCardName>();
n->setGivenName(name);
vCard->belCard->setName(n);
}
}
const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getName() ? vCard->belCard->getName()->getGivenName().c_str() : NULL;
return result;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard || !sip_address) return;
shared_ptr<belcard::BelCardImpp> impp = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
impp->setValue(sip_address);
vCard->belCard->addImpp(impp);
}
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard) return;
shared_ptr<belcard::BelCardImpp> impp;
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strcmp(value, sip_address) == 0) {
impp = *it;
break;
}
}
if (impp) {
vCard->belCard->removeImpp(impp);
}
}
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard || !sip_address) return;
if (vCard->belCard->getImpp().size() > 0) {
const shared_ptr<belcard::BelCardImpp> impp = vCard->belCard->getImpp().front();
impp->setValue(sip_address);
} else {
shared_ptr<belcard::BelCardImpp> impp = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
impp->setValue(sip_address);
vCard->belCard->addImpp(impp);
}
}
bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
bctbx_list_t *result = NULL;
if (!vCard) return NULL;
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strncmp(value, "sip:", 4) == 0) {
result = bctbx_list_append(result, (char *)value);
}
}
return result;
}
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
if (!vCard || !phone) return;
shared_ptr<belcard::BelCardPhoneNumber> phone_number = belcard::BelCardGeneric::create<belcard::BelCardPhoneNumber>();
phone_number->setValue(phone);
vCard->belCard->addPhoneNumber(phone_number);
}
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
if (!vCard) return;
shared_ptr<belcard::BelCardPhoneNumber> tel;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
const char *value = (*it)->getValue().c_str();
if (strcmp(value, phone) == 0) {
tel = *it;
break;
}
}
if (tel) {
vCard->belCard->removePhoneNumber(tel);
}
}
bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
bctbx_list_t *result = NULL;
if (!vCard) return NULL;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
const char *value = (*it)->getValue().c_str();
result = bctbx_list_append(result, (char *)value);
}
return result;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
if (!vCard) return;
if (vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
org->setValue(organization);
} else {
shared_ptr<belcard::BelCardOrganization> org = belcard::BelCardGeneric::create<belcard::BelCardOrganization>();
org->setValue(organization);
vCard->belCard->addOrganization(org);
}
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
if (vCard && vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
return org->getValue().c_str();
}
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
char uuid[64];
if (vCard) {
if (linphone_vcard_get_uid(vCard)) {
return FALSE;
}
if (sal_generate_uuid(uuid, sizeof(uuid)) == 0) {
char vcard_uuid[sizeof(uuid)+4];
snprintf(vcard_uuid, sizeof(vcard_uuid), "urn:%s", uuid);
linphone_vcard_set_uid(vCard, vcard_uuid);
return TRUE;
}
}
return FALSE;
}
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) {
if (!vCard || !uid) return;
shared_ptr<belcard::BelCardUniqueId> uniqueId = belcard::BelCardGeneric::create<belcard::BelCardUniqueId>();
uniqueId->setValue(uid);
vCard->belCard->setUniqueId(uniqueId);
}
const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) {
if (vCard && vCard->belCard->getUniqueId()) {
return vCard->belCard->getUniqueId()->getValue().c_str();
}
return NULL;
}
void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) {
if (!vCard) {
return;
}
if (vCard->etag) {
ms_free(vCard->etag);
vCard->etag = NULL;
}
vCard->etag = ms_strdup(etag);
}
const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->etag;
}
void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) {
if (!vCard) {
return;
}
if (vCard->url) {
ms_free(vCard->url);
vCard->url = NULL;
}
vCard->url = ms_strdup(url);
}
const char* linphone_vcard_get_url(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
return vCard->url;
}
#define VCARD_MD5_HASH_SIZE 16
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) {
unsigned char digest[VCARD_MD5_HASH_SIZE];
const char *text = NULL;
if (!vCard) {
return;
}
text = linphone_vcard_as_vcard4_string(vCard);
bctbx_md5((unsigned char *)text, strlen(text), digest);
vCard->md5 = (unsigned char *)ms_malloc(sizeof(digest));
memcpy(vCard->md5, digest, sizeof(digest));
}
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) {
unsigned char *previous_md5 = vCard->md5;
unsigned char *new_md5 = NULL;
int result = -1;
if (!previous_md5) {
return result;
}
linphone_vcard_compute_md5_hash(vCard);
new_md5 = vCard->md5;
result = memcmp(new_md5, previous_md5, VCARD_MD5_HASH_SIZE);
ms_free(previous_md5);
ms_free(new_md5);
return result;
}
bool_t linphone_core_vcard_supported(void) {
return TRUE;
}
#ifdef __cplusplus
}
#endif

View file

@ -1,243 +1,294 @@
/*
vcard.h
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef LINPHONE_VCARD_H
#define LINPHONE_VCARD_H
#include <mediastreamer2/mscommon.h>
#ifndef LINPHONE_PUBLIC
#define LINPHONE_PUBLIC MS2_PUBLIC
#endif
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @addtogroup carddav_vcard
* @{
*/
/**
* Linphone vCard context object.
*/
typedef struct _LinphoneVcardContext LinphoneVcardContext;
/**
* The LinphoneVcard object.
*/
typedef struct _LinphoneVcard LinphoneVcard;
/**
* Creates a LinphoneVcard object that has a pointer to an empty vCard
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void);
/**
* Deletes a LinphoneVcard object properly
* @param[in] vCard the LinphoneVcard to destroy
*/
LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard);
/**
* Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] file the path to the file to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *file);
/**
* Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] buffer the buffer to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise.
* @param[in] buffer the buffer to parse
* @return a LinphoneVcard if one could be parsed, or NULL otherwise
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Returns the vCard4 representation of the LinphoneVcard.
* @param[in] vCard the LinphoneVcard
* @return a const char * that represents the vCard
*/
LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVcard *vCard);
/**
* Sets the FN attribute of the vCard (which is mandatory).
* @param[in] vCard the LinphoneVcard
* @param[in] name the display name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the FN attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the display name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard);
/**
* Adds a SIP address in the vCard, using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the SIP address to add
*/
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Removes a SIP address in the vCard (if it exists), using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the SIP address to remove
*/
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Edits the preferred SIP address in the vCard (or the first one), using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the new SIP address
*/
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL
* @param[in] vCard the LinphoneVcard
* @return \mslist{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
/**
* Adds a phone number in the vCard, using the TEL property
* @param[in] vCard the LinphoneVcard
* @param[in] phone the phone number to add
*/
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone);
/**
* Removes a phone number in the vCard (if it exists), using the TEL property
* @param[in] vCard the LinphoneVcard
* @param[in] phone the phone number to remove
*/
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone);
/**
* Returns the list of phone numbers (as string) in the vCard (all the TEL attributes) or NULL
* @param[in] vCard the LinphoneVcard
* @return \mslist{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard);
/**
* Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL
* @param[in] vCard the LinphoneVcard
* @return \mslist{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
/**
* Fills the Organization field of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] organization the Organization
*/
LINPHONE_PUBLIC void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization);
/**
* Gets the Organization of the vCard
* @param[in] vCard the LinphoneVcard
* @return the Organization of the vCard or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_organization(const LinphoneVcard *vCard);
/**
* Generates a random unique id for the vCard.
* If is required to be able to synchronize the vCard with a CardDAV server
* @param[in] vCard the LinphoneVcard
* @return TRUE if operation is successful, otherwise FALSE (for example if it already has an unique ID)
*/
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard);
/**
* Sets the unique ID of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] uid the unique id
*/
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid);
/**
* Gets the UID of the vCard
* @param[in] vCard the LinphoneVcard
* @return the UID of the vCard, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_uid(const LinphoneVcard *vCard);
/**
* Sets the eTAG of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] etag the eTAG
*/
LINPHONE_PUBLIC void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag);
/**
* Gets the eTag of the vCard
* @param[in] vCard the LinphoneVcard
* @return the eTag of the vCard in the CardDAV server, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_etag(const LinphoneVcard *vCard);
/**
* Sets the URL of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] url the URL
*/
LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVcard *vCard, const char *url);
/**
* Gets the URL of the vCard
* @param[in] vCard the LinphoneVcard
* @return the URL of the vCard in the CardDAV server, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_url(const LinphoneVcard *vCard);
/**
* Computes the md5 hash for the vCard
* @param[in] vCard the LinphoneVcard
*/
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard);
/**
* Compares the previously computed md5 hash (using linphone_vcard_compute_md5_hash) with the current one
* @param[in] vCard the LinphoneVcard
* @return 0 if the md5 hasn't changed, 1 otherwise
*/
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
/*
vcard.h
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef LINPHONE_VCARD_H
#define LINPHONE_VCARD_H
#include <mediastreamer2/mscommon.h>
#ifndef LINPHONE_PUBLIC
#define LINPHONE_PUBLIC MS2_PUBLIC
#endif
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @addtogroup carddav_vcard
* @{
*/
/**
* The LinphoneVcardContext object.
*/
typedef struct _LinphoneVcardContext LinphoneVcardContext;
/**
* Creates a vCard context to reuse the same BelCardParser object
* @return a new LinphoneVcardContext object
*/
LINPHONE_PUBLIC LinphoneVcardContext* linphone_vcard_context_new(void);
/**
* Destroys the vCard context
* @param[in] context a LinphoneVcardContext object
*/
LINPHONE_PUBLIC void linphone_vcard_context_destroy(LinphoneVcardContext *context);
/**
* Gets the user data set in the LinphoneVcardContext
* @param[in] context a LinphoneVcardContext object
* @return the user data pointer
*/
LINPHONE_PUBLIC void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context);
/**
* Sets the user data in the LinphoneVcardContext
* @param[in] context a LinphoneVcardContext object
* @param[in] data the user data pointer
*/
LINPHONE_PUBLIC void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data);
/**
* The LinphoneVcard object.
*/
typedef struct _LinphoneVcard LinphoneVcard;
/**
* Creates a LinphoneVcard object that has a pointer to an empty vCard
* @return a new LinphoneVcard object
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void);
/**
* Deletes a LinphoneVcard object properly
* @param[in] vCard the LinphoneVcard to destroy
*/
LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard);
/**
* Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] file the path to the file to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *file);
/**
* Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] buffer the buffer to parse
* @return \mslist{LinphoneVcard}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise.
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
* @param[in] buffer the buffer to parse
* @return a LinphoneVcard if one could be parsed, or NULL otherwise
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer);
/**
* Returns the vCard4 representation of the LinphoneVcard.
* @param[in] vCard the LinphoneVcard
* @return a const char * that represents the vCard
*/
LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVcard *vCard);
/**
* Sets the FN attribute of the vCard (which is mandatory).
* @param[in] vCard the LinphoneVcard
* @param[in] name the display name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the FN attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the display name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard);
/**
* Sets the family name in the N attribute of the vCard.
* @param[in] vCard the LinphoneVcard
* @param[in] name the family name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_family_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the family name in the N attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the family name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_family_name(const LinphoneVcard *vCard);
/**
* Sets the given name in the N attribute of the vCard.
* @param[in] vCard the LinphoneVcard
* @param[in] name the given name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the given name in the N attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the given name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard);
/**
* Adds a SIP address in the vCard, using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the SIP address to add
*/
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Removes a SIP address in the vCard (if it exists), using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the SIP address to remove
*/
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Edits the preferred SIP address in the vCard (or the first one), using the IMPP property
* @param[in] vCard the LinphoneVcard
* @param[in] sip_address the new SIP address
*/
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address);
/**
* Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL
* @param[in] vCard the LinphoneVcard
* @return \mslist{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
/**
* Adds a phone number in the vCard, using the TEL property
* @param[in] vCard the LinphoneVcard
* @param[in] phone the phone number to add
*/
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone);
/**
* Removes a phone number in the vCard (if it exists), using the TEL property
* @param[in] vCard the LinphoneVcard
* @param[in] phone the phone number to remove
*/
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone);
/**
* Returns the list of phone numbers (as string) in the vCard (all the TEL attributes) or NULL
* @param[in] vCard the LinphoneVcard
* @return \mslist{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard);
/**
* Fills the Organization field of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] organization the Organization
*/
LINPHONE_PUBLIC void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization);
/**
* Gets the Organization of the vCard
* @param[in] vCard the LinphoneVcard
* @return the Organization of the vCard or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_organization(const LinphoneVcard *vCard);
/**
* Generates a random unique id for the vCard.
* If is required to be able to synchronize the vCard with a CardDAV server
* @param[in] vCard the LinphoneVcard
* @return TRUE if operation is successful, otherwise FALSE (for example if it already has an unique ID)
*/
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard);
/**
* Sets the unique ID of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] uid the unique id
*/
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid);
/**
* Gets the UID of the vCard
* @param[in] vCard the LinphoneVcard
* @return the UID of the vCard, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_uid(const LinphoneVcard *vCard);
/**
* Sets the eTAG of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] etag the eTAG
*/
LINPHONE_PUBLIC void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag);
/**
* Gets the eTag of the vCard
* @param[in] vCard the LinphoneVcard
* @return the eTag of the vCard in the CardDAV server, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_etag(const LinphoneVcard *vCard);
/**
* Sets the URL of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] url the URL
*/
LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVcard *vCard, const char *url);
/**
* Gets the URL of the vCard
* @param[in] vCard the LinphoneVcard
* @return the URL of the vCard in the CardDAV server, otherwise NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_url(const LinphoneVcard *vCard);
/**
* Computes the md5 hash for the vCard
* @param[in] vCard the LinphoneVcard
*/
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard);
/**
* Compares the previously computed md5 hash (using linphone_vcard_compute_md5_hash) with the current one
* @param[in] vCard the LinphoneVcard
* @return 0 if the md5 hasn't changed, 1 otherwise
*/
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,152 +1,158 @@
/*
vcard_stubs.c
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "vcard.h"
struct _LinphoneVcardContext {
void *user_data;
};
LinphoneVcardContext* linphone_vcard_context_new(void) {
LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1);
context->user_data = NULL;
return context;
}
void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
if (context) {
ms_free(context);
}
}
void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) {
if (context) context->user_data = data;
}
struct _LinphoneVcard {
void *dummy;
};
LinphoneVcard* linphone_vcard_new(void) {
return NULL;
}
void linphone_vcard_free(LinphoneVcard *vCard) {
}
MSList* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) {
return NULL;
}
MSList* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
}
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
}
MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
return FALSE;
}
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) {
}
const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) {
}
const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) {
}
const char* linphone_vcard_get_url(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) {
}
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) {
return FALSE;
}
/*
vcard_stubs.c
Copyright (C) 2015 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "vcard.h"
struct _LinphoneVcardContext {
void *user_data;
};
LinphoneVcardContext* linphone_vcard_context_new(void) {
LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1);
context->user_data = NULL;
return context;
}
void linphone_vcard_context_destroy(LinphoneVcardContext *context) {
if (context) {
ms_free(context);
}
}
void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) {
return context ? context->user_data : NULL;
}
void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) {
if (context) context->user_data = data;
}
struct _LinphoneVcard {
void *dummy;
};
LinphoneVcard* linphone_vcard_new(void) {
return NULL;
}
void linphone_vcard_free(LinphoneVcard *vCard) {
}
MSList* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) {
return NULL;
}
MSList* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) {
return NULL;
}
const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_family_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_family_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
}
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
}
MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
return FALSE;
}
void linphone_vcard_set_uid(LinphoneVcard *vCard, const char *uid) {
}
const char* linphone_vcard_get_uid(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_etag(LinphoneVcard *vCard, const char * etag) {
}
const char* linphone_vcard_get_etag(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url) {
}
const char* linphone_vcard_get_url(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_compute_md5_hash(LinphoneVcard *vCard) {
}
bool_t linphone_vcard_compare_md5_hash(LinphoneVcard *vCard) {
return FALSE;
}
bool_t linphone_core_vcard_supported(void) {
return FALSE;
}

View file

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphone.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#define CONFIG_FILE ".linphone-call-history.db"

View file

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphone.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#ifdef HAVE_GTK_OSX
#include <gtkosxapplication.h>

View file

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "linphone.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#include <gdk/gdkkeysyms.h>
static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list);
@ -611,7 +611,7 @@ static int get_friend_weight(const LinphoneFriend *lf){
}
static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *lf2){
int w1,w2;
int w1,w2,ret;
w1=get_friend_weight(lf1);
w2=get_friend_weight(lf2);
if (w1==w2){
@ -619,13 +619,19 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *
const LinphoneAddress *addr1,*addr2;
addr1=linphone_friend_get_address(lf1);
addr2=linphone_friend_get_address(lf2);
u1=linphone_address_get_username(addr1);
u2=linphone_address_get_username(addr2);
if (u1 && u2) return strcasecmp(u1,u2);
if (u1) return 1;
else return -1;
u1=linphone_address_get_display_name(addr1) ? linphone_address_get_display_name(addr1) : linphone_address_get_username(addr1);
u2=linphone_address_get_display_name(addr2) ? linphone_address_get_display_name(addr2) : linphone_address_get_username(addr2);
if (u1 && u2) {
ret = strcasecmp(u1,u2);
} else if (u1) {
ret = 1;
} else {
ret = -1;
}
} else {
ret = w2-w1;
}
return w2-w1;
return ret;
}
static bctbx_list_t *sort_friend_list(const bctbx_list_t *friends){

View file

@ -364,6 +364,7 @@ LINPHONE_PUBLIC void linphone_gtk_reload_sound_devices(void);
LINPHONE_PUBLIC void linphone_gtk_reload_video_devices(void);
LINPHONE_PUBLIC bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact);
LINPHONE_PUBLIC gboolean linphone_gtk_auto_answer_enabled(void);
LINPHONE_PUBLIC void linphone_gtk_auto_answer_delay_changed(GtkSpinButton *spinbutton, gpointer user_data);
LINPHONE_PUBLIC void linphone_gtk_update_status_bar_icons(void);
LINPHONE_PUBLIC void linphone_gtk_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data);

View file

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphone.h"
#include "lpconfig.h"
#include "liblinphone_gitversion.h"
#include <bctoolbox/bc_vfs.h>
#include <bctoolbox/vfs.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -502,7 +502,7 @@ void linphone_gtk_show_about(void){
}
g_free(license);
}
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),LIBLINPHONE_GIT_VERSION);
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),linphone_core_get_version());
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about),linphone_gtk_get_ui_config("title","Linphone"));
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),linphone_gtk_get_ui_config("home","http://www.linphone.org"));
if (logo) {
@ -2190,7 +2190,7 @@ int main(int argc, char *argv[]){
return -1;
}
if(version) {
g_message("Linphone version %s.", LIBLINPHONE_GIT_VERSION);
g_message("Linphone version %s.", linphone_core_get_version());
return 0;
}

View file

@ -121,7 +121,7 @@ static void _resize_video_window(GtkWidget *video_window, MSVideoSize vsize){
}
}
static gint resize_video_window(LinphoneCall *call){
static gboolean resize_video_window(LinphoneCall *call){
const LinphoneCallParams *params=linphone_call_get_current_params(call);
if (params){
MSVideoSize vsize=linphone_call_params_get_received_video_size(params);
@ -232,6 +232,18 @@ static gboolean video_window_moved(GtkWidget *widget, GdkEvent *event, gpointer
return FALSE;
}
static gint do_gtk_widget_destroy(GtkWidget *w){
gtk_widget_destroy(w);
return FALSE;
}
static void schedule_video_controls_disapearance(GtkWidget *w){
gint timeout=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"timeout"));
if (timeout != 0) g_source_remove(timeout);
timeout=g_timeout_add(3000,(GSourceFunc)do_gtk_widget_destroy,w);
g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout));
}
static GtkWidget *show_video_controls(GtkWidget *video_window){
GtkWidget *w;
w=(GtkWidget*)g_object_get_data(G_OBJECT(video_window),"controls");
@ -240,7 +252,6 @@ static GtkWidget *show_video_controls(GtkWidget *video_window){
const char *stock_button=isfullscreen ? GTK_STOCK_LEAVE_FULLSCREEN : GTK_STOCK_FULLSCREEN;
gint response_id=isfullscreen ? GTK_RESPONSE_NO : GTK_RESPONSE_YES ;
GtkWidget *image = gtk_image_new_from_icon_name(linphone_gtk_get_ui_config("stop_call_icon_name","linphone-stop-call"), GTK_ICON_SIZE_BUTTON);
gint timeout;
GtkWidget *button;
w=gtk_dialog_new_with_buttons("",GTK_WINDOW(video_window),GTK_DIALOG_DESTROY_WITH_PARENT,stock_button,response_id,NULL);
gtk_window_set_opacity(GTK_WINDOW(w),0.5);
@ -255,18 +266,14 @@ static GtkWidget *show_video_controls(GtkWidget *video_window){
gtk_widget_show(button);
gtk_dialog_add_action_widget(GTK_DIALOG(w),button,GTK_RESPONSE_APPLY);
g_signal_connect(w,"response",(GCallback)on_controls_response,video_window);
timeout=g_timeout_add(3000,(GSourceFunc)gtk_widget_destroy,w);
g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout));
schedule_video_controls_disapearance(w);
g_signal_connect(w,"destroy",(GCallback)on_controls_destroy,NULL);
g_object_set_data(G_OBJECT(w),"video_window",video_window);
g_object_set_data(G_OBJECT(video_window),"controls",w);
set_video_controls_position(video_window);
gtk_widget_show(w);
}else{
gint timeout=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"timeout"));
g_source_remove(timeout);
timeout=g_timeout_add(3000,(GSourceFunc)gtk_widget_destroy,w);
g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout));
schedule_video_controls_disapearance(w);
}
return w;
}

View file

@ -714,7 +714,7 @@ int sal_call_accept(SalOp*h);
int sal_call_decline(SalOp *h, SalReason reason, const char *redirection /*optional*/);
int sal_call_update(SalOp *h, const char *subject, bool_t no_user_consent);
SalMediaDescription * sal_call_get_remote_media_description(SalOp *h);
SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
LINPHONE_PUBLIC SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
int sal_call_refer(SalOp *h, const char *refer_to);
int sal_call_refer_with_replaces(SalOp *h, SalOp *other_call_h);
int sal_call_accept_refer(SalOp *h);
@ -870,6 +870,8 @@ LINPHONE_PUBLIC int sal_get_transport_timeout(const Sal* sal);
void sal_set_dns_servers(Sal *sal, const MSList *servers);
LINPHONE_PUBLIC void sal_enable_dns_srv(Sal *sal, bool_t enable);
LINPHONE_PUBLIC bool_t sal_dns_srv_enabled(const Sal *sal);
LINPHONE_PUBLIC void sal_enable_dns_search(Sal *sal, bool_t enable);
LINPHONE_PUBLIC bool_t sal_dns_search_enabled(const Sal *sal);
LINPHONE_PUBLIC void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file);
LINPHONE_PUBLIC const char *sal_get_dns_user_hosts_file(const Sal *sal);
unsigned int sal_get_random(void);

View file

@ -24,28 +24,35 @@ if(ANDROID)
find_package(Java REQUIRED COMPONENTS Development)
set(JNI_CLASSES
"org.linphone.core.ErrorInfoImpl"
"org.linphone.core.LinphoneAddressImpl"
"org.linphone.core.LinphoneAuthInfoImpl"
"org.linphone.core.LinphoneBufferImpl"
"org.linphone.core.LinphoneCallImpl"
"org.linphone.core.LinphoneCallLogImpl"
"org.linphone.core.LinphoneCallParamsImpl"
"org.linphone.core.LinphoneCallStatsImpl"
"org.linphone.core.LinphoneChatMessageImpl"
"org.linphone.core.LinphoneChatRoomImpl"
"org.linphone.core.LinphoneConferenceImpl"
"org.linphone.core.LinphoneConferenceParamsImpl"
"org.linphone.core.LinphoneContentImpl"
"org.linphone.core.LinphoneCoreFactoryImpl"
"org.linphone.core.LinphoneCoreImpl"
"org.linphone.core.LinphoneFriendImpl"
"org.linphone.core.LinphoneProxyConfigImpl"
"org.linphone.core.PayloadTypeImpl"
"org.linphone.core.LpConfigImpl"
"org.linphone.core.LinphoneInfoMessageImpl"
"org.linphone.core.LinphoneEventImpl"
"org.linphone.core.LinphoneFriendImpl"
"org.linphone.core.LinphoneFriendListImpl"
"org.linphone.core.LinphoneInfoMessageImpl"
"org.linphone.core.LinphoneNatPolicyImpl"
"org.linphone.core.LinphonePlayerImpl"
"org.linphone.core.LinphoneProxyConfigImpl"
"org.linphone.core.LpConfigImpl"
"org.linphone.core.PayloadTypeImpl"
"org.linphone.core.PresenceActivityImpl"
"org.linphone.core.PresenceModelImpl"
"org.linphone.core.PresenceNoteImpl"
"org.linphone.core.PresencePersonImpl"
"org.linphone.core.PresenceServiceImpl"
"org.linphone.core.ErrorInfoImpl"
"org.linphone.core.TunnelConfigImpl"
)

View file

@ -1,3 +1,22 @@
/*
LinphoneContent.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
/**

View file

@ -170,7 +170,7 @@ public interface LinphoneCore {
}
/**
* Describes firewall policy.
*
* @deprecated
*/
static public class FirewallPolicy {
@ -561,6 +561,42 @@ public interface LinphoneCore {
return mStringValue;
}
}
static public final class LinphoneLimeState {
static private Vector<LinphoneLimeState> values = new Vector<LinphoneLimeState>();
/**
* Disabled
*/
static public final LinphoneLimeState Disabled = new LinphoneLimeState(0, "None");
/**
* Mandatory
*/
static public final LinphoneLimeState Mandatory = new LinphoneLimeState(1,"Mandatory");
/**
* Preferred
*/
static public final LinphoneLimeState Preferred = new LinphoneLimeState(2,"Preferred");
protected final int mValue;
private final String mStringValue;
private LinphoneLimeState(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static LinphoneLimeState fromInt(int value) {
for (int i=0; i<values.size();i++) {
LinphoneLimeState menc = (LinphoneLimeState) values.elementAt(i);
if (menc.mValue == value) return menc;
}
throw new RuntimeException("LinphoneLimeState not found ["+value+"]");
}
public String toString() {
return mStringValue;
}
}
/**
* Set the context of creation of the LinphoneCore.
@ -1098,10 +1134,16 @@ public interface LinphoneCore {
/**
* Teturns true if the underlying sdk support video
* Returns true if the underlying sdk support video
*
* */
boolean isVideoSupported();
/**
* Returns true if the underlying sdk support vCards
*
* */
boolean isVCardSupported();
/**
* Enables video globally.
@ -1116,6 +1158,7 @@ public interface LinphoneCore {
*
**/
void enableVideo(boolean vcap_enabled, boolean display_enabled);
/**
* Returns TRUE if video is enabled, FALSE otherwise.
*
@ -1127,6 +1170,7 @@ public interface LinphoneCore {
* @param stun_server Stun server address and port, such as stun.linphone.org or stun.linphone.org:3478
*/
void setStunServer(String stun_server);
/**
* Get STUN server
* @return stun server address if previously set.
@ -1136,24 +1180,49 @@ public interface LinphoneCore {
/**
* Sets policy regarding workarounding NATs
* @param pol one of the FirewallPolicy members.
* @deprecated
**/
void setFirewallPolicy(FirewallPolicy pol);
/**
* @return previously set firewall policy.
* @deprecated
*/
FirewallPolicy getFirewallPolicy();
/**
* Create a new LinphoneNatPolicy object with every policies being disabled.
* @return A new LinphoneNatPolicy object.
*/
LinphoneNatPolicy createNatPolicy();
/**
* Set the policy to use to pass through NATs/firewalls.
* It may be overridden by a NAT policy for a specific proxy config.
* @param policy LinphoneNatPolicy object
*/
void setNatPolicy(LinphoneNatPolicy policy);
/**
* Get The policy that is used to pass through NATs/firewalls.
* It may be overridden by a NAT policy for a specific proxy config.
* @return LinphoneNatPolicy object in use.
*/
LinphoneNatPolicy getNatPolicy();
/**
* Initiates an outgoing call given a destination LinphoneAddress
*
* @param addr the destination of the call {@link #LinphoneAddress }.
* @param params call parameters {@link #LinphoneCallParams }
*
*<br>The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}. .
*<br>The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}.
*
* @return a {@link #LinphoneCall LinphoneCall} object
* @throws LinphoneCoreException in case of failure
**/
LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException ;
LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException;
/**
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
*
@ -2313,4 +2382,10 @@ public interface LinphoneCore {
* @param path The path from where plugins are to be loaded.
**/
public void reloadMsPlugins(String path);
public boolean isLimeEncryptionAvailable();
public void setLimeEncryption(LinphoneLimeState lime);
public LinphoneLimeState getLimeEncryption();
}

View file

@ -162,10 +162,30 @@ public interface LinphoneFriend {
*/
void setName(String name);
/**
* get name of this friend
* get a name of this friend
* @return
*/
String getName();
/**
* Set a family name for this friend
* @param name
*/
void setFamilyName(String name);
/**
* get a family name of this friend
* @return
*/
String getFamilyName();
/**
* Set a given name for this friend
* @param name
*/
void setGivenName(String name);
/**
* get a given name of this friend
* @return
*/
String getGivenName();
/**
* Set an organization for this friend
* @param organization

View file

@ -0,0 +1,113 @@
/*
LinphoneNatPolicy.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
/**
* Policy to use to pass through NATs/firewalls.
*
*/
public interface LinphoneNatPolicy {
/**
* Clear a NAT policy (deactivate all protocols and unset the STUN server).
*/
void clear();
/**
* Tell whether STUN is enabled.
* @return Boolean value telling whether STUN is enabled.
*/
boolean stunEnabled();
/**
* Enable STUN.
* If TURN is also enabled, TURN will be used instead of STUN.
* @param enable Boolean value telling whether to enable STUN.
*/
void enableStun(boolean enable);
/**
* Tell whether TURN is enabled.
* @return Boolean value telling whether TURN is enabled.
*/
boolean turnEnabled();
/**
* Enable TURN.
* If STUN is also enabled, it is ignored and TURN is used.
* @param enable Boolean value telling whether to enable TURN.
*/
void enableTurn(boolean enable);
/**
* Tell whether ICE is enabled.
* @return Boolean value telling whether ICE is enabled.
*/
boolean iceEnabled();
/**
* Enable ICE.
* ICE can be enabled without STUN/TURN, in which case only the local candidates will be used.
* @param enable Boolean value telling whether to enable ICE.
*/
void enableIce(boolean enable);
/**
* Tell whether uPnP is enabled.
* @return Boolean value telling whether uPnP is enabled.
*/
boolean upnpEnabled();
/**
* Enable uPnP.
* This has the effect to disable every other policies (ICE, STUN and TURN).
* @param enable Boolean value telling whether to enable uPnP.
*/
void enableUpnp(boolean enable);
/**
* Get the STUN/TURN server to use with this NAT policy.
* Used when STUN or TURN are enabled.
* @return The STUN server used by this NAT policy.
*/
String getStunServer();
/**
* Set the STUN/TURN server to use with this NAT policy.
* Used when STUN or TURN are enabled.
* @param stun_server The STUN server to use with this NAT policy.
*/
void setStunServer(String stun_server);
/**
* Get the username used to authenticate with the STUN/TURN server.
* The authentication will search for a LinphoneAuthInfo with this username.
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
* @return The username used to authenticate with the STUN/TURN server.
*/
String getStunServerUsername();
/**
* Set the username used to authenticate with the STUN/TURN server.
* The authentication will search for a LinphoneAuthInfo with this username.
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
* @param username The username used to authenticate with the STUN/TURN server.
*/
void setStunServerUsername(String username);
}

View file

@ -0,0 +1,111 @@
/*
LinphoneXmlRpcRequest.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
import java.util.Vector;
public interface LinphoneXmlRpcRequest {
interface LinphoneXmlRpcRequestListener {
void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request);
}
public static class ArgType {
static private Vector<ArgType> values = new Vector<ArgType>();
private final int mValue;
private final String mStringValue;
public final int value() { return mValue; }
public final static ArgType None = new ArgType(0, "None");
public final static ArgType Int = new ArgType(1, "Int");
public final static ArgType String = new ArgType(2, "String");
private ArgType(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static ArgType fromInt(int value) {
for (int i=0; i < values.size(); i++) {
ArgType state = (ArgType) values.elementAt(i);
if (state.mValue == value) return state;
}
throw new RuntimeException("ArgType not found [" + value + "]");
}
public String toString() {
return mStringValue;
}
public int toInt() {
return mValue;
}
}
public static class Status {
static private Vector<Status> values = new Vector<Status>();
private final int mValue;
private final String mStringValue;
public final int value() { return mValue; }
public final static Status Pending = new Status(0, "Pending");
public final static Status Ok = new Status(1, "Ok");
public final static Status Failed = new Status(2, "Failed");
private Status(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static Status fromInt(int value) {
for (int i=0; i < values.size(); i++) {
Status state = (Status) values.elementAt(i);
if (state.mValue == value) return state;
}
throw new RuntimeException("Status not found [" + value + "]");
}
public String toString() {
return mStringValue;
}
public int toInt() {
return mValue;
}
}
void addIntArg(int arg);
void addStringArg(String arg);
String getContent();
Status getStatus();
int getIntResponse();
String getStringResponse();
void setListener(LinphoneXmlRpcRequestListener listener);
}

View file

@ -0,0 +1,24 @@
/*
LinphoneXmlRpcSession.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public interface LinphoneXmlRpcSession {
void sendRequest(LinphoneXmlRpcRequest request);
}

View file

@ -1,3 +1,22 @@
/*
LinphoneContentImpl.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public class LinphoneContentImpl implements LinphoneContent {

View file

@ -109,8 +109,12 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled);
private native boolean isVideoEnabled(long nativePtr);
private native boolean isVideoSupported(long nativePtr);
private native boolean isVCardSupported(long nativePtr);
private native void setFirewallPolicy(long nativePtr, int enum_value);
private native int getFirewallPolicy(long nativePtr);
private native Object createNatPolicy(long nativePtr);
private native void setNatPolicy(long nativePtr, long policyPtr);
private native Object getNatPolicy(long nativePtr);
private native void setStunServer(long nativePtr, String stun_server);
private native String getStunServer(long nativePtr);
private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
@ -525,15 +529,27 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized boolean isVideoSupported() {
return isVideoSupported(nativePtr);
}
public synchronized boolean isVCardSupported() {
return isVCardSupported(nativePtr);
}
public synchronized FirewallPolicy getFirewallPolicy() {
return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr));
}
public synchronized String getStunServer() {
return getStunServer(nativePtr);
}
public synchronized void setFirewallPolicy(FirewallPolicy pol) {
setFirewallPolicy(nativePtr,pol.value());
}
public synchronized LinphoneNatPolicy createNatPolicy() {
return (LinphoneNatPolicy)createNatPolicy(nativePtr);
}
public synchronized void setNatPolicy(LinphoneNatPolicy policy) {
setNatPolicy(nativePtr, ((LinphoneNatPolicyImpl)policy).mNativePtr);
}
public synchronized LinphoneNatPolicy getNatPolicy() {
return (LinphoneNatPolicy)getNatPolicy(nativePtr);
}
public synchronized String getStunServer() {
return getStunServer(nativePtr);
}
public synchronized void setStunServer(String stunServer) {
setStunServer(nativePtr, stunServer);
}
@ -1670,4 +1686,19 @@ class LinphoneCoreImpl implements LinphoneCore {
public void reloadMsPlugins(String path) {
reloadMsPlugins(nativePtr, path);
}
private native boolean isLimeEncryptionAvailable(long nativePtr);
public synchronized boolean isLimeEncryptionAvailable() {
return isLimeEncryptionAvailable(nativePtr);
}
private native void setLimeEncryption(long nativePtr, int value);
public synchronized void setLimeEncryption(LinphoneLimeState lime) {
setLimeEncryption(nativePtr, lime.mValue);
}
private native int getLimeEncryption(long nativePtr);
public synchronized LinphoneLimeState getLimeEncryption() {
return LinphoneLimeState.fromInt(getLimeEncryption(nativePtr));
}
}

View file

@ -142,6 +142,28 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
return getName(nativePtr);
}
private native void setFamilyName(long nativePtr, String name);
@Override
public void setFamilyName(String name) {
setFamilyName(nativePtr, name);
}
private native String getFamilyName(long nativePtr);
public String getFamilyName() {
return getFamilyName(nativePtr);
}
private native void setGivenName(long nativePtr, String name);
@Override
public void setGivenName(String name) {
setGivenName(nativePtr, name);
}
private native String getGivenName(long nativePtr);
public String getGivenName() {
return getGivenName(nativePtr);
}
private native void setOrganization(long nativePtr, String organization);
@Override
public void setOrganization(String organization) {

View file

@ -0,0 +1,125 @@
/*
LinphoneNatPolicyImpl.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public class LinphoneNatPolicyImpl implements LinphoneNatPolicy {
protected final long mNativePtr;
private native Object getCore(long nativePtr);
private native void clear(long nativePtr);
private native boolean stunEnabled(long nativePtr);
private native void enableStun(long nativePtr, boolean enable);
private native boolean turnEnabled(long nativePtr);
private native void enableTurn(long nativePtr, boolean enable);
private native boolean iceEnabled(long nativePtr);
private native void enableIce(long nativePtr, boolean enable);
private native boolean upnpEnabled(long nativePtr);
private native void enableUpnp(long nativePtr, boolean enable);
private native String getStunServer(long nativePtr);
private native void setStunServer(long nativePtr, String stun_server);
private native String getStunServerUsername(long nativePtr);
private native void setStunServerUsername(long nativePtr, String username);
protected LinphoneNatPolicyImpl(long nativePtr) {
mNativePtr = nativePtr;
}
private synchronized LinphoneCore getCore() {
return (LinphoneCore)getCore(mNativePtr);
}
public void clear() {
synchronized(getCore()) {
clear(mNativePtr);
}
}
public boolean stunEnabled() {
synchronized(getCore()) {
return stunEnabled(mNativePtr);
}
}
public void enableStun(boolean enable) {
synchronized(getCore()) {
enableStun(mNativePtr, enable);
}
}
public boolean turnEnabled() {
synchronized(getCore()) {
return turnEnabled(mNativePtr);
}
}
public void enableTurn(boolean enable) {
synchronized(getCore()) {
enableTurn(mNativePtr, enable);
}
}
public boolean iceEnabled() {
synchronized(getCore()) {
return iceEnabled(mNativePtr);
}
}
public void enableIce(boolean enable) {
synchronized(getCore()) {
enableIce(mNativePtr, enable);
}
}
public boolean upnpEnabled() {
synchronized(getCore()) {
return upnpEnabled(mNativePtr);
}
}
public void enableUpnp(boolean enable) {
synchronized(getCore()) {
enableUpnp(mNativePtr, enable);
}
}
public String getStunServer() {
synchronized(getCore()) {
return getStunServer(mNativePtr);
}
}
public void setStunServer(String stun_server) {
synchronized(getCore()) {
setStunServer(mNativePtr, stun_server);
}
}
public String getStunServerUsername() {
synchronized(getCore()) {
return getStunServerUsername(mNativePtr);
}
}
public void setStunServerUsername(String username) {
synchronized(getCore()) {
setStunServerUsername(mNativePtr, username);
}
}
}

View file

@ -0,0 +1,84 @@
/*
LinphoneXmlRpcRequestImpl.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public class LinphoneXmlRpcRequestImpl implements LinphoneXmlRpcRequest {
protected long nativePtr;
protected LinphoneXmlRpcRequestImpl(long aNativePtr) {
nativePtr = aNativePtr;
}
private native long newLinphoneXmlRpcRequest(String methodName, int returnType);
public LinphoneXmlRpcRequestImpl(String methodName, ArgType returnType) {
nativePtr = newLinphoneXmlRpcRequest(methodName, returnType.value());
}
public long getNativePtr() {
return nativePtr;
}
private native void unref(long ptr);
protected void finalize(){
unref(nativePtr);
}
private native void addIntArg(long ptr, int arg);
@Override
public void addIntArg(int arg) {
addIntArg(nativePtr, arg);
}
private native void addStringArg(long ptr, String arg);
@Override
public void addStringArg(String arg) {
addStringArg(nativePtr, arg);
}
private native String getContent(long ptr);
@Override
public String getContent() {
return getContent(nativePtr);
}
private native int getStatus(long ptr);
@Override
public Status getStatus() {
return Status.fromInt(getStatus(nativePtr));
}
private native int getIntResponse(long ptr);
@Override
public int getIntResponse() {
return getIntResponse(nativePtr);
}
private native String getStringResponse(long ptr);
@Override
public String getStringResponse() {
return getStringResponse(nativePtr);
}
private native void setListener(long ptr, LinphoneXmlRpcRequestListener listener);
@Override
public void setListener(LinphoneXmlRpcRequestListener listener) {
setListener(nativePtr, listener);
}
}

View file

@ -0,0 +1,43 @@
/*
LinphoneXmlRpcSessionImpl.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public class LinphoneXmlRpcSessionImpl implements LinphoneXmlRpcSession {
protected long nativePtr;
private native long newLinphoneXmlRpcSession(long nativePtr, String url);
public LinphoneXmlRpcSessionImpl(LinphoneCore lc, String url) {
nativePtr = newLinphoneXmlRpcSession(((LinphoneCoreImpl)lc).nativePtr, url);
}
public long getNativePtr() {
return nativePtr;
}
private native void unref(long ptr);
protected void finalize(){
unref(nativePtr);
}
private native void sendRequest(long ptr, long requestPtr);
@Override
public void sendRequest(LinphoneXmlRpcRequest request) {
sendRequest(nativePtr, ((LinphoneXmlRpcRequestImpl)request).getNativePtr());
}
}

@ -1 +1 @@
Subproject commit ea379434c6c725a734b418449b799d5ef8a030c2
Subproject commit 8ffb9d13a73d035e173c9a0ef42c3b701be07827

2
oRTP

@ -1 +1 @@
Subproject commit 96f89c62589f9fb84c78be2a092dc94a016ec775
Subproject commit 9857d82970226055b279a13fc566933f3014da1b

View file

@ -129,6 +129,7 @@ set(VCARD_FILES
set(OTHER_FILES
tester_hosts
local_tester_hosts
messages.db
)

View file

@ -30,7 +30,7 @@ struct _Account{
typedef struct _Account Account;
Account *account_new(LinphoneAddress *identity, const char *unique_id){
static Account *account_new(LinphoneAddress *identity, const char *unique_id){
char *modified_username;
Account *obj=ms_new0(Account,1);
@ -121,7 +121,7 @@ static void account_created_auth_requested_cb(LinphoneCore *lc, const char *user
}
// TEMPORARY CODE: remove line above when flexisip is updated, this is not needed anymore!
void account_create_on_server(Account *account, const LinphoneProxyConfig *refcfg){
void account_create_on_server(Account *account, const LinphoneProxyConfig *refcfg, const char* phone_alias){
LinphoneCoreVTable vtable={0};
LinphoneCore *lc;
LinphoneAddress *tmp_identity=linphone_address_clone(account->modified_identity);
@ -144,6 +144,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
linphone_address_set_secure(tmp_identity, FALSE);
linphone_address_set_password(tmp_identity,account->password);
linphone_address_set_header(tmp_identity,"X-Create-Account","yes");
if (phone_alias) linphone_address_set_header(tmp_identity, "X-Phone-Alias", phone_alias);
tmp=linphone_address_as_string(tmp_identity);
linphone_proxy_config_set_identity(cfg,tmp);
ms_free(tmp);
@ -191,7 +192,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
linphone_core_destroy(lc);
}
LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg){
static LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg,const char* phone_alias){
LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
const char *identity=linphone_proxy_config_get_identity(cfg);
LinphoneAddress *id_addr=linphone_address_new(identity);
@ -217,7 +218,7 @@ LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyC
ms_free(tmp);
if (create_account){
account_create_on_server(account,cfg);
account_create_on_server(account,cfg,phone_alias);
}
/*remove previous auth info to avoid mismatching*/
@ -240,6 +241,6 @@ void linphone_core_manager_check_accounts(LinphoneCoreManager *m){
for(it=linphone_core_get_proxy_config_list(m->lc);it!=NULL;it=it->next){
LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)it->data;
account_manager_check_account(am,cfg);
account_manager_check_account(am,cfg,m->phone_alias);
}
}

View file

@ -342,7 +342,7 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag
BC_ASSERT_PTR_NOT_NULL(conference = linphone_core_get_conference(marie->lc));
if(conference) {
bctbx_list_t *participants = linphone_conference_get_participants(conference);
BC_ASSERT_EQUAL(bctbx_list_size(participants), 2, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(participants), 2, unsigned int, "%u");
bctbx_list_free_with_data(participants, (void(*)(void *))linphone_address_destroy);
}
@ -716,7 +716,7 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin
BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallStreamsRunning,3,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,5,10000));
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 2, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_calls(marie->lc)), 2, unsigned int, "%u");
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc));
} else {
@ -811,7 +811,7 @@ static void eject_from_4_participants_conference(void) {
BC_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc));
BC_ASSERT_TRUE(linphone_core_is_in_conference(marie->lc));
BC_ASSERT_EQUAL(linphone_core_get_conference_size(marie->lc),3, int, "%d");
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 3, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_calls(marie->lc)), 3, unsigned int, "%u");
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc));
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(michelle->lc));

View file

@ -1232,15 +1232,30 @@ void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie
end_call(pauline, marie);
}
static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay, bool_t ipv6) {
LinphoneCoreManager* marie = linphone_core_manager_new2("marie_rc", FALSE);
LinphoneCoreManager* pauline = linphone_core_manager_new2(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc", FALSE);
if (ipv6) {
linphone_core_enable_ipv6(marie->lc, TRUE);
linphone_core_enable_ipv6(pauline->lc, TRUE);
}
linphone_core_manager_start(marie, TRUE);
linphone_core_manager_start(pauline, TRUE);
_call_with_ice_base(pauline,marie,caller_with_ice,callee_with_ice,random_ports,forced_relay);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_with_ice(void){
_call_with_ice(TRUE,TRUE,FALSE,FALSE);
_call_with_ice(TRUE,TRUE,FALSE,FALSE,FALSE);
}
static void call_with_ice_ipv6(void) {
if (liblinphone_tester_ipv6_available()) {
_call_with_ice(TRUE, TRUE, FALSE, FALSE, TRUE);
} else {
ms_warning("Test skipped, no ipv6 available");
}
}
/*ICE is not expected to work in this case, however this should not crash*/
@ -1264,19 +1279,19 @@ static void call_with_ice_no_sdp(void){
}
static void call_with_ice_random_ports(void){
_call_with_ice(TRUE,TRUE,TRUE,FALSE);
_call_with_ice(TRUE,TRUE,TRUE,FALSE,FALSE);
}
static void call_with_ice_forced_relay(void) {
_call_with_ice(TRUE, TRUE, TRUE, TRUE);
_call_with_ice(TRUE, TRUE, TRUE, TRUE, FALSE);
}
static void ice_to_not_ice(void){
_call_with_ice(TRUE,FALSE,FALSE,FALSE);
_call_with_ice(TRUE,FALSE,FALSE,FALSE,FALSE);
}
static void not_ice_to_ice(void){
_call_with_ice(FALSE,TRUE,FALSE,FALSE);
_call_with_ice(FALSE,TRUE,FALSE,FALSE,FALSE);
}
static void ice_added_by_reinvite(void){
@ -1311,15 +1326,11 @@ static void ice_added_by_reinvite(void){
linphone_call_params_destroy(params);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection));
/*wait for the ICE reINVITE*/
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection));
end_call(pauline, marie);
@ -4189,10 +4200,10 @@ static void _call_with_network_switch(bool_t use_ice, bool_t with_socket_refresh
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
if (use_ice) {
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
/*wait for ICE reINVITE to complete*/
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
}
/*marie looses the network and reconnects*/
@ -4279,10 +4290,10 @@ static void call_with_sip_and_rtp_independant_switches(void){
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
if (use_ice) {
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
/*wait for ICE reINVITE to complete*/
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
}
/*marie looses the SIP network and reconnects*/
linphone_core_set_sip_network_reachable(marie->lc, FALSE);
@ -4359,7 +4370,7 @@ static void call_logs_migrate(void) {
BC_ASSERT_TRUE(linphone_core_get_call_history_size(laure->lc) == 10);
for (; i < bctbx_list_size(laure->lc->call_logs); i++) {
LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, i);
LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, (int)i);
LinphoneCallStatus state = linphone_call_log_get_status(log);
LinphoneCallDir direction = linphone_call_log_get_dir(log);
@ -4799,17 +4810,19 @@ static void v6_call_over_nat_64(void){
}
static void call_with_ice_in_ipv4_with_v6_enabled(void) {
if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/
LinphoneCoreManager* marie = linphone_core_manager_new("marie_v4proxy_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_v4proxy_rc");
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
liblinphonetester_ipv6=TRUE;
_call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/
if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/
liblinphonetester_ipv6=TRUE;
marie = linphone_core_manager_new("marie_v4proxy_rc");
pauline = linphone_core_manager_new("pauline_v4proxy_rc");
_call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/
} else ms_warning("Test skipped, need both ipv6 and v4 available");
}
@ -4873,6 +4886,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call rejected without 403 because of wrong credential", call_rejected_without_403_because_wrong_credentials),
TEST_NO_TAG("Call rejected without 403 because of wrong credential and no auth req cb", call_rejected_without_403_because_wrong_credentials_no_auth_req_cb),
TEST_ONE_TAG("Call with ICE", call_with_ice, "ICE"),
TEST_ONE_TAG("Call with ICE IPv6", call_with_ice_ipv6, "ICE"),
TEST_ONE_TAG("Call with ICE without SDP", call_with_ice_no_sdp, "ICE"),
TEST_ONE_TAG("Call with ICE (random ports)", call_with_ice_random_ports, "ICE"),
TEST_ONE_TAG("Call with ICE (forced relay)", call_with_ice_forced_relay, "ICE"),

View file

@ -886,11 +886,11 @@ static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVide
BC_ASSERT_TRUE(call_ok = call(pauline, marie));
if (!call_ok) goto end;
BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection));
/* Wait for ICE reINVITEs to complete. */
BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)
&& wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection));
check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts);
nb_media_starts++;

View file

@ -23,6 +23,7 @@
#include "private.h"
#if HAVE_SIPP
void check_rtcp(LinphoneCall *call) {
MSTimeSpec ts;
@ -45,7 +46,6 @@ void check_rtcp(LinphoneCall *call) {
}
FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres) {
#if HAVE_SIPP
char *dest;
char *command;
FILE *file;
@ -65,14 +65,10 @@ FILE *sip_start(const char *senario, const char* dest_username, const char *pass
ms_free(command);
ms_free(dest);
return file;
#else
return NULL;
#endif
}
static FILE *sip_start_recv(const char *senario) {
#if HAVE_SIPP
char *command;
FILE *file;
@ -83,9 +79,6 @@ static FILE *sip_start_recv(const char *senario) {
file = popen(command, "r");
ms_free(command);
return file;
#else
return NULL;
#endif
}
static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list) {
@ -359,6 +352,7 @@ static test_t tests[] = {
TEST_NO_TAG("Call with multiple video mline in sdp", call_with_multiple_video_mline_in_sdp),
TEST_NO_TAG("Call invite 200ok without contact header", call_invite_200ok_without_contact_header)
};
#endif
test_suite_t complex_sip_call_test_suite = {
"Complex SIP Case",
@ -366,6 +360,11 @@ test_suite_t complex_sip_call_test_suite = {
NULL,
liblinphone_tester_before_each,
liblinphone_tester_after_each,
#if HAVE_SIPP
sizeof(tests) / sizeof(tests[0]),
tests
#else
0,
NULL
#endif
};

View file

@ -1,4 +1,4 @@
liblinphone_tester@sip.example.org secret
liblinphone_tester@sip.example.org secret liblinphone_tester +331234567890
liblinphone_tester@auth.example.org secret
liblinphone_tester@auth1.example.org secret
tester@sip.example.org secret

View file

@ -962,7 +962,7 @@ static void dos_module_trigger(void) {
linphone_core_manager_destroy(pauline);
}
#if HAVE_SIPP
static void test_subscribe_notify_with_sipp_publisher(void) {
char *scen;
FILE * sipp_out;
@ -1004,7 +1004,8 @@ static void test_subscribe_notify_with_sipp_publisher(void) {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
//does not work because sipp seams not able to manage 2 call id in case file
//does not work because sipp seams not able to manage 2 call id in case file
#if 0
static void test_subscribe_notify_with_sipp_publisher_double_publish(void) {
char *scen;
@ -1046,6 +1047,7 @@ static void test_subscribe_notify_with_sipp_publisher_double_publish(void) {
linphone_core_manager_destroy(pauline);
}
#endif
#endif
static void test_publish_unpublish(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
@ -1142,6 +1144,7 @@ static void test_list_subscribe (void) {
linphone_core_manager_destroy(laure);
}
#if HAVE_SIPP
static void test_subscribe_on_wrong_dialog(void) {
char *scen;
FILE * sipp_out;
@ -1162,6 +1165,7 @@ static void test_subscribe_on_wrong_dialog(void) {
linphone_core_manager_destroy(marie);
}
#endif
test_t flexisip_tests[] = {
@ -1183,15 +1187,19 @@ test_t flexisip_tests[] = {
TEST_NO_TAG("Call ipv6 to ipv6", call_with_ipv6),
TEST_NO_TAG("Call ipv6 to ipv4", call_ipv6_to_ipv4),
TEST_NO_TAG("Call ipv4 to ipv6", call_ipv4_to_ipv6),
#if HAVE_SIPP
TEST_ONE_TAG("Subscribe Notify with sipp publisher", test_subscribe_notify_with_sipp_publisher, "LeaksMemory"),
/*TEST_ONE_TAG("Subscribe Notify with sipp double publish", test_subscribe_notify_with_sipp_publisher_double_publish, "LeaksMemory"),*/
#endif
TEST_NO_TAG("Publish/unpublish", test_publish_unpublish),
TEST_ONE_TAG("List subscribe", test_list_subscribe,"LeaksMemory"),
TEST_NO_TAG("File transfer message rcs to external body client", file_transfer_message_rcs_to_external_body_client),
TEST_ONE_TAG("File transfer message external body to rcs client", file_transfer_message_external_body_to_rcs_client, "LeaksMemory"),
TEST_ONE_TAG("File transfer message external body to external body client", file_transfer_message_external_body_to_external_body_client, "LeaksMemory"),
TEST_NO_TAG("DoS module trigger by sending a lot of chat messages", dos_module_trigger),
#if HAVE_SIPP
TEST_NO_TAG("Subscribe on wrong dialog", test_subscribe_on_wrong_dialog)
#endif
};
test_suite_t flexisip_test_suite = {"Flexisip", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,

View file

@ -229,6 +229,7 @@ int main (int argc, char *argv[])
#endif
liblinphone_tester_init(NULL);
linphone_core_set_log_level(ORTP_ERROR);
for(i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--verbose") == 0) {

View file

@ -262,6 +262,7 @@ typedef struct _LinphoneCoreManager {
LinphoneEvent *lev;
bool_t decline_subscribe;
int number_of_bcunit_error_at_creation;
char* phone_alias;
} LinphoneCoreManager;
typedef struct _LinphoneConferenceServer {
@ -280,8 +281,9 @@ typedef struct _LinphoneCallTestParams {
void liblinphone_tester_add_suites(void);
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file);
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, const char* phone_alias);
void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias);
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file);
void linphone_core_manager_stop(LinphoneCoreManager *mgr);

View file

@ -362,7 +362,7 @@ static void text_message_with_send_error(void) {
linphone_chat_room_send_chat_message(chat_room,msg);
/* check transient msg list: the msg should be in it, and should be the only one */
BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1));
@ -370,7 +370,7 @@ static void text_message_with_send_error(void) {
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d");
/* the msg should have been discarded from transient list after an error */
BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u");
sal_set_send_error(marie->lc->sal, 0);
@ -396,7 +396,7 @@ static void text_message_with_external_body(void) {
linphone_chat_room_send_chat_message(chat_room,msg);
/* check transient msg list: the msg should be in it, and should be the only one */
BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
@ -405,7 +405,7 @@ static void text_message_with_external_body(void) {
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d");
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1, int, "%d");
BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u");
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
@ -615,7 +615,7 @@ static void file_transfer_2_messages_simultaneously(void) {
cbs = linphone_chat_message_get_callbacks(msg2);
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, unsigned int, "%u");
if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) == 0) {
linphone_chat_room_send_chat_message(pauline_room,msg);
linphone_chat_room_send_chat_message(pauline_room,msg2);
@ -623,7 +623,7 @@ static void file_transfer_2_messages_simultaneously(void) {
msg = linphone_chat_message_clone(marie->stat.last_received_chat_message);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2));
msg2 = marie->stat.last_received_chat_message;
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, unsigned int, "%u");
if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) {
char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)));
const bctbx_list_t *it = linphone_core_get_chat_rooms(marie->lc);
@ -634,23 +634,23 @@ static void file_transfer_2_messages_simultaneously(void) {
}
ms_error("%s", buf);
}
cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
linphone_chat_message_download_file(msg);
cbs = linphone_chat_message_get_callbacks(msg2);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
linphone_chat_message_download_file(msg2);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,2));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,4, int, "%d");
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,2, int, "%d");
compare_files(send_filepath, receive_filepath);
linphone_chat_message_unref(msg);
}
}
@ -986,10 +986,10 @@ static void lime_unit(void) {
uint8_t receiverZID[12];
xmlDocPtr cacheBuffer;
FILE *CACHE;
/**** Low level tests using on cache file to extract keys, encrypt/decrypt ****/
/**** use functions that are not directly used by external entities ****/
/* create and load cache file */
CACHE = fopen_from_write_dir("ZIDCache.xml", "wb");
fprintf (CACHE, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cache><selfZID>ef7692d0792a67491ae2d44e</selfZID><peer><ZID>005dbe0399643d953a2202dd</ZID><rs1>9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045</rs1><aux>f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e</aux><rs2>2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899</rs2><uri>pipo1@pipo.com</uri><sndKey>963c57bb28e62068d2df23e8f9b771932d3c57bb28e62068d2df23e8f9b77193</sndKey><rcvKey>05d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193</rcvKey><sndSId>5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193</sndSId><rcvSId>02ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193</rcvSId><sndIndex>00000069</sndIndex><rcvIndex>000001e8</rcvIndex><pvs>01</pvs></peer><peer><ZID>1234567889643d953a2202ee</ZID><rs1>9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045</rs1><aux>f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e</aux><rs2>2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899</rs2><uri>pipo1@pipo.com</uri><sndKey>123456789012345678901234567890123456765431262068d2df23e8f9b77193</sndKey><rcvKey>25d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193</rcvKey><sndSId>f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193</sndSId><rcvSId>22ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193</rcvSId><sndIndex>00000001</sndIndex><rcvIndex>00000000</rcvIndex><pvs>01</pvs></peer></cache>");
@ -1001,7 +1001,7 @@ static void lime_unit(void) {
/* parse it to an xmlDoc */
cacheBuffer = xmlParseDoc(cacheBufferString);
ms_free(cacheBufferString);
/* get data from cache : sender */
associatedKeys.peerURI = (uint8_t *)malloc(15);
memcpy(associatedKeys.peerURI, "pipo1@pipo.com", 15);
@ -1010,14 +1010,14 @@ static void lime_unit(void) {
BC_ASSERT_EQUAL(retval, 0, int, "%d");
BC_ASSERT_EQUAL(associatedKeys.associatedZIDNumber, 2, int, "%d"); /* there are 2 keys associated to pipo1@pipo.com address in the cache above*/
ms_message("Get cached key by URI, for sender, return %d keys", associatedKeys.associatedZIDNumber);
for (i=0; i<associatedKeys.associatedZIDNumber; i++) {
printHex("ZID", associatedKeys.peerKeys[i]->peerZID, 12);
printHex("key", associatedKeys.peerKeys[i]->key, 32);
printHex("sessionID", associatedKeys.peerKeys[i]->sessionId, 32);
ms_message("session index %d\n", associatedKeys.peerKeys[i]->sessionIndex);
}
/* get data from cache : receiver */
memcpy(associatedKey.peerZID, targetZID, 12);
retval = lime_getCachedRcvKeyByZid(cacheBuffer, &associatedKey);
@ -1026,35 +1026,35 @@ static void lime_unit(void) {
printHex("Key", associatedKey.key, 32);
printHex("sessionID", associatedKey.sessionId, 32);
ms_message("session index %d\n", associatedKey.sessionIndex);
/* encrypt/decrypt a msg */
lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage);
lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, (uint32_t)strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage);
printHex("Ciphered", encryptedMessage, strlen((char *)encryptedMessage));
/* invert sender and receiverZID to decrypt/authenticate */
memcpy(receiverZID, associatedKeys.peerKeys[0]->peerZID, 12);
memcpy(associatedKeys.peerKeys[0]->peerZID, senderZID, 12);
retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage);
retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, (uint32_t)strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage);
BC_ASSERT_EQUAL(retval, 0, int, "%d");
BC_ASSERT_STRING_EQUAL((char *)plainMessage, (char *)PLAIN_TEXT_TEST_MESSAGE);
ms_message("Decrypt and auth returned %d\nPlain text is %s\n", retval, plainMessage);
/* update receiver data */
associatedKey.sessionIndex++;
associatedKey.key[0]++;
associatedKey.sessionId[0]++;
retval = lime_setCachedKey(cacheBuffer, &associatedKey, LIME_RECEIVER);
BC_ASSERT_EQUAL(retval, 0, int, "%d");
/* update sender data */
associatedKeys.peerKeys[0]->sessionIndex++;
associatedKeys.peerKeys[0]->key[0]++;
associatedKeys.peerKeys[0]->sessionId[0]++;
retval = lime_setCachedKey(cacheBuffer, associatedKeys.peerKeys[0], LIME_SENDER);
BC_ASSERT_EQUAL(retval, 0, int, "%d");
/* free memory */
lime_freeKeys(&associatedKeys);
/* write the file */
/* dump the xml document into a string */
xmlDocDumpFormatMemoryEnc(cacheBuffer, &xmlStringOutput, &xmlStringLength, "UTF-8", 0);
@ -1064,7 +1064,7 @@ static void lime_unit(void) {
xmlFree(xmlStringOutput);
fclose(CACHE);
xmlFreeDoc(cacheBuffer);
/**** Higher level tests using 2 caches to encrypt/decrypt a msg ****/
/* Create Alice cache file and then load it */
CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "wb");
@ -1077,7 +1077,7 @@ static void lime_unit(void) {
/* parse it to an xmlDoc */
cacheBufferAlice = xmlParseDoc(cacheBufferString);
ms_free(cacheBufferString);
/* Create Bob cache file and then load it */
CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb");
fprintf(CACHE, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cache><selfZID>005dbe0399643d953a2202dd</selfZID><peer><ZID>ef7692d0792a67491ae2d44e</ZID><rs1>9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045</rs1><aux>f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e</aux><rs2>2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899</rs2><uri>sip:marie@sip.example.org</uri><rcvKey>9111ebeb52e50edcc6fcb3eea1a2d3ae3c2c75d3668923e83c59d0f472455150</rcvKey><sndKey>60f020a3fe11dc2cc0e1e8ed9341b4cd14944db806ca4fc95456bbe45d95c43a</sndKey><rcvSId>5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193</rcvSId><sndSId>bcffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193</sndSId><rcvIndex>00000080</rcvIndex><sndIndex>000001cf</sndIndex><pvs>01</pvs></peer><peer><ZID>1234567889643d953a2202ee</ZID><rs1>9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045</rs1><aux>f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e</aux><rs2>2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899</rs2><uri>sip:marie@sip.example.org</uri><sndKey>81e6e6362c34dc974263d1f77cbb9a8d6d6a718330994379099a8fa19fb12faa</sndKey><rcvKey>25d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193</rcvKey><sndSId>f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193</sndSId><rcvSId>22ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193</rcvSId><sndIndex>0000002e</sndIndex><rcvIndex>00000000</rcvIndex><pvs>01</pvs></peer></cache>");
@ -1089,20 +1089,20 @@ static void lime_unit(void) {
/* parse it to an xmlDoc */
cacheBufferBob = xmlParseDoc(cacheBufferString);
ms_free(cacheBufferString);
/* encrypt a msg */
retval = lime_createMultipartMessage(cacheBufferAlice, (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, (uint8_t *)"sip:pauline@sip.example.org", &multipartMessage);
BC_ASSERT_EQUAL(retval, 0, int, "%d");
if (retval == 0) {
ms_message("Encrypted msg created is %s", multipartMessage);
}
/* decrypt the multipart msg */
retval = lime_decryptMultipartMessage(cacheBufferBob, multipartMessage, &decryptedMessage);
BC_ASSERT_EQUAL(retval, 0, int, "%d");
if (retval == 0) {
BC_ASSERT_STRING_EQUAL((char *)decryptedMessage, (char *)PLAIN_TEXT_TEST_MESSAGE);
@ -1110,7 +1110,7 @@ static void lime_unit(void) {
}
free(multipartMessage);
free(decryptedMessage);
/* update ZID files */
/* dump the xml document into a string */
xmlDocDumpFormatMemoryEnc(cacheBufferAlice, &xmlStringOutput, &xmlStringLength, "UTF-8", 0);
@ -1119,15 +1119,15 @@ static void lime_unit(void) {
fwrite(xmlStringOutput, 1, xmlStringLength, CACHE);
xmlFree(xmlStringOutput);
fclose(CACHE);
xmlDocDumpFormatMemoryEnc(cacheBufferBob, &xmlStringOutput, &xmlStringLength, "UTF-8", 0);
/* write it to the file */
CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb+");
fwrite(xmlStringOutput, 1, xmlStringLength, CACHE);
xmlFree(xmlStringOutput);
fclose(CACHE);
xmlFreeDoc(cacheBufferAlice);
xmlFreeDoc(cacheBufferBob);
} else {
@ -1190,9 +1190,9 @@ int check_no_strange_time(void* data,int argc, char** argv,char** cNames) {
return 0;
}
void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, int expected ){
void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, unsigned int expected ){
bctbx_list_t* messages = linphone_chat_room_get_history_range(chatroom, x, y);
BC_ASSERT_EQUAL(bctbx_list_size(messages), expected, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), expected, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void *))linphone_chat_message_unref);
}
@ -1288,16 +1288,16 @@ static void history_count(void) {
BC_ASSERT_PTR_NOT_NULL(chatroom);
if (chatroom){
messages=linphone_chat_room_get_history(chatroom,10);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 10, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 10, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
messages=linphone_chat_room_get_history(chatroom,1);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
messages=linphone_chat_room_get_history(chatroom,0);
BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(chatroom), 1270, int, "%d");
BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270, unsigned int, "%u");
/*check the second most recent msg*/
BC_ASSERT_PTR_NOT_NULL(messages);
@ -1312,23 +1312,23 @@ static void history_count(void) {
/*test offset+limit: retrieve the 42th latest msg only and check its content*/
messages=linphone_chat_room_get_history_range(chatroom, 42, 42);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1, unsigned int, "%u");
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text((LinphoneChatMessage *)messages->data), "If you open yourself to the Tao is intangible and evasive, yet prefers to keep us at the mercy of the kingdom, then all of the streams of hundreds of valleys because of its limitless possibilities.");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
/*test offset without limit*/
messages = linphone_chat_room_get_history_range(chatroom, 1265, -1);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270-1265, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
/*test limit without offset*/
messages = linphone_chat_room_get_history_range(chatroom, 0, 5);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 6, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 6, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
/*test invalid start*/
messages = linphone_chat_room_get_history_range(chatroom, 1265, 1260);
BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270-1265, unsigned int, "%u");
bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
}
@ -1352,6 +1352,19 @@ static void text_status_after_destroying_chat_room(void) {
linphone_core_manager_destroy(marie);
}
static void file_transfer_not_sent_if_invalid_url(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, "<sip:Jehan@sip.linphone.org>");
LinphoneChatMessage *msg = create_message_from_nowebcam(chatroom);
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
linphone_core_set_file_transfer_server(marie->lc, "INVALID URL");
linphone_chat_room_send_chat_message(chatroom, msg);
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
linphone_core_manager_destroy(marie);
}
void file_transfer_io_error_base(char *server_url, bool_t destroy_room) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, "<sip:Jehan@sip.linphone.org>");
@ -1366,25 +1379,13 @@ void file_transfer_io_error_base(char *server_url, bool_t destroy_room) {
linphone_core_delete_chat_room(marie->lc, chatroom);
BC_ASSERT_FALSE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
} else {
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 3000));
}
linphone_core_manager_destroy(marie);
}
static void file_transfer_not_sent_if_invalid_url(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, "<sip:Jehan@sip.linphone.org>");
LinphoneChatMessage *msg = create_message_from_nowebcam(chatroom);
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
linphone_core_set_file_transfer_server(marie->lc, "INVALID URL");
linphone_chat_room_send_chat_message(chatroom, msg);
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
linphone_core_manager_destroy(marie);
}
static void file_transfer_not_sent_if_host_not_found(void) {
file_transfer_io_error_base("https://not_existing_url.com", FALSE);
file_transfer_io_error_base("https://not-existing-url.com", FALSE);
}
static void file_transfer_not_sent_if_url_moved_permanently(void) {
@ -1476,7 +1477,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo
for (i = 0; i < strlen(message); i++) {
BC_ASSERT_FALSE(linphone_chat_message_put_char(rtt_message, message[i]));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c");
}
linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message);
@ -1488,11 +1489,11 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo
LinphoneChatMessage *marie_msg = NULL;
LinphoneChatMessage *pauline_msg = NULL;
if (do_not_store_rtt_messages_in_sql_storage) {
BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 0, int , "%i");
BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 0, int , "%i");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(marie_messages), 0, unsigned int , "%u");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(pauline_messages), 0, unsigned int , "%u");
} else {
BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 1, int , "%i");
BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 1, int , "%i");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(marie_messages), 1, unsigned int , "%u");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(pauline_messages), 1, unsigned int , "%u");
if (!marie_messages || !pauline_messages) {
goto end;
}
@ -1569,11 +1570,11 @@ static void real_time_text_conversation(void) {
for (i = 0; i < strlen(message1_1); i++) {
linphone_chat_message_put_char(pauline_rtt_message, message1_1[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message1_1[i], char, "%c");
linphone_chat_message_put_char(marie_rtt_message, message1_2[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(pauline_chat_room), message1_2[i], char, "%c");
}
@ -1605,11 +1606,11 @@ static void real_time_text_conversation(void) {
for (i = 0; i < strlen(message2_1); i++) {
linphone_chat_message_put_char(pauline_rtt_message, message2_1[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message2_1[i], char, "%c");
linphone_chat_message_put_char(marie_rtt_message, message2_2[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(pauline_chat_room), message2_2[i], char, "%c");
}
@ -1680,7 +1681,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_
for (i = 0; i < strlen(message); i++) {
linphone_chat_message_put_char(rtt_message, message[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c");
}
@ -1689,7 +1690,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_
} else if (end_with_lf) {
linphone_chat_message_put_char(rtt_message, lf);
}
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, strlen(message), 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)strlen(message), 1000));
BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1));
linphone_chat_message_unref(rtt_message);
}
@ -1794,7 +1795,7 @@ static void real_time_text_copy_paste(void) {
linphone_chat_message_put_char(rtt_message, message[i-1]);
if (i % 4 == 0) {
int j;
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i, 1000));
for (j = 4; j > 0; j--) {
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i-j], char, "%c");
}
@ -1835,7 +1836,7 @@ test_t message_tests[] = {
TEST_NO_TAG("Transfer message with http proxy", file_transfer_with_http_proxy),
TEST_NO_TAG("Transfer message with upload io error", transfer_message_with_upload_io_error),
TEST_NO_TAG("Transfer message with download io error", transfer_message_with_download_io_error),
TEST_ONE_TAG("Transfer message upload cancelled", transfer_message_upload_cancelled, "LeaksMemory"),
TEST_NO_TAG("Transfer message upload cancelled", transfer_message_upload_cancelled),
TEST_NO_TAG("Transfer message download cancelled", transfer_message_download_cancelled),
TEST_ONE_TAG("Transfer message using external body url", file_transfer_using_external_body_url, "LeaksMemory"),
TEST_NO_TAG("Transfer 2 messages simultaneously", file_transfer_2_messages_simultaneously),
@ -1846,7 +1847,7 @@ test_t message_tests[] = {
TEST_NO_TAG("Lime text message", lime_text_message),
TEST_NO_TAG("Lime text message to non lime", lime_text_message_to_non_lime),
TEST_NO_TAG("Lime transfer message", lime_transfer_message),
TEST_ONE_TAG("Lime transfer message from history", lime_transfer_message_from_history,"LeaksMemory"),
TEST_NO_TAG("Lime transfer message from history", lime_transfer_message_from_history),
TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption),
TEST_NO_TAG("Lime unitary", lime_unit),
#ifdef SQLITE_STORAGE_ENABLED
@ -1858,7 +1859,7 @@ test_t message_tests[] = {
TEST_NO_TAG("Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url),
TEST_NO_TAG("Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found),
TEST_NO_TAG("Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently),
TEST_NO_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom),
TEST_ONE_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom, "LeaksMemory"),
TEST_ONE_TAG("Real Time Text message", real_time_text_message, "RTT"),
TEST_ONE_TAG("Real Time Text SQL storage", real_time_text_sql_storage, "RTT"),
TEST_ONE_TAG("Real Time Text SQL storage with RTT messages not stored", real_time_text_sql_storage_rtt_disabled, "RTT"),

View file

@ -647,45 +647,73 @@ static void presence_list_subscribe_io_error(void) {
test_presence_list_subscribe_with_error(TRUE);
}
static void long_term_presence_base(const char* addr, bool_t exist) {
LinphoneFriend* friend;
static void long_term_presence_base(const char* addr, bool_t exist, const char* contact) {
LinphoneFriend* friend2;
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
friend=linphone_core_create_friend_with_address(pauline->lc,addr);
linphone_friend_edit(friend);
linphone_friend_enable_subscribes(friend,TRUE);
linphone_friend_done(friend);
linphone_core_add_friend(pauline->lc,friend);
friend2=linphone_core_create_friend_with_address(pauline->lc,addr);
linphone_friend_edit(friend2);
linphone_friend_enable_subscribes(friend2,TRUE);
linphone_friend_done(friend2);
linphone_core_add_friend(pauline->lc,friend2);
if (exist) {
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOnline,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOnline, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend)), LinphonePresenceBasicStatusOpen, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend2)), LinphonePresenceBasicStatusOpen, int, "%d");
BC_ASSERT_STRING_EQUAL(linphone_presence_model_get_contact(linphone_friend_get_presence_model(friend2)), contact);
} else {
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOffline,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOffline, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend)), LinphonePresenceBasicStatusClosed, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend2)), LinphonePresenceBasicStatusClosed, int, "%d");
BC_ASSERT_PTR_NULL(linphone_presence_model_get_contact(linphone_friend_get_presence_model(friend2)));
}
linphone_friend_unref(friend);
linphone_friend_unref(friend2);
linphone_core_manager_destroy(pauline);
}
static void long_term_presence_existing_friend(void) {
// this friend is not online, but is known from flexisip to be registered (see flexisip/userdb.conf),
// so we expect to get a report that he is currently not online
long_term_presence_base("sip:liblinphone_tester@sip.example.org", TRUE);
long_term_presence_base("sip:liblinphone_tester@sip.example.org", TRUE, "sip:liblinphone_tester@sip.example.org");
}
static void long_term_presence_inexistent_friend(void) {
long_term_presence_base("sip:random_unknown@sip.example.org", FALSE);
long_term_presence_base("sip:random_unknown@sip.example.org", FALSE, NULL);
}
static void long_term_presence_phone_alias(void) {
long_term_presence_base("sip:+331234567890@sip.example.org", TRUE, "sip:liblinphone_tester@sip.example.org");
}
static const char* random_phone_number(void) {
static char phone[10];
int i;
phone[0] = '+';
for (i = 1; i < 10; i++) {
phone[i] = '0' + rand() % 10;
}
return phone;
}
static void long_term_presence_phone_alias2(void) {
LinphoneCoreManager *marie = linphone_core_manager_new3("marie_rc", TRUE, random_phone_number());
char * identity = linphone_address_as_string_uri_only(marie->identity);
LinphoneAddress * phone_addr = linphone_core_interpret_url(marie->lc, marie->phone_alias);
char *phone_addr_uri = linphone_address_as_string(phone_addr);
long_term_presence_base(phone_addr_uri, TRUE, identity);
ms_free(identity);
ms_free(phone_addr_uri);
linphone_address_destroy(phone_addr);
linphone_core_manager_destroy(marie);
}
static void long_term_presence_list(void) {
LinphoneFriend *f1, *f2;
LinphoneFriendList* friends;
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
enable_publish(pauline, TRUE);
enable_publish(pauline, FALSE);
enable_deflate_content_encoding(pauline, FALSE);
friends = linphone_core_create_friend_list(pauline->lc);
@ -726,6 +754,8 @@ test_t presence_server_tests[] = {
TEST_NO_TAG("Presence list, io error",presence_list_subscribe_io_error),
TEST_NO_TAG("Long term presence existing friend",long_term_presence_existing_friend),
TEST_NO_TAG("Long term presence inexistent friend",long_term_presence_inexistent_friend),
TEST_NO_TAG("Long term presence phone alias",long_term_presence_phone_alias),
TEST_NO_TAG("Long term presence phone alias 2",long_term_presence_phone_alias2),
TEST_NO_TAG("Long term presence list",long_term_presence_list),
};

View file

@ -529,7 +529,7 @@ static void simple_subscribe_with_friend_from_rc(void) {
LinphoneCoreManager *marie = presence_linphone_core_manager_new_with_rc_name("marie", "pauline_as_friend_rc");
LinphoneFriend *pauline_as_friend;
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_friend_list(marie->lc)), 1, unsigned int , "%u");
if (bctbx_list_size(linphone_core_get_friend_list(marie->lc))>0) {
pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data;

View file

@ -406,7 +406,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) {
for (i = 0; i < strlen(message); i++) {
linphone_chat_message_put_char(rtt_message, message[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c");
}
linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message);

View file

@ -15,6 +15,7 @@ realm=sip.example.org
[proxy_0]
realm=sip.example.org
reg_proxy=sip2.linphone.org;transport=tls
reg_route=sip2.linphone.org;transport=tls
reg_identity=sip:pauline@sip.example.org

View file

@ -15,6 +15,7 @@ realm=sip.example.org
[proxy_0]
realm=sip.example.org
reg_proxy=sip2.linphone.org;transport=tcp
reg_route=sip2.linphone.org;transport=tcp
reg_identity=sip:pauline@sip.example.org

View file

@ -505,7 +505,7 @@ static LinphoneCoreManager* configure_lcm(void) {
if (transport_supported(LinphoneTransportTls)) {
LinphoneCoreManager *lcm=linphone_core_manager_new2( "multi_account_rc", FALSE);
stats *counters=&lcm->stat;
BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc))));
BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,(int)bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc))));
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0, int, "%d");
return lcm;
}
@ -567,7 +567,7 @@ static void transport_change(void){
register_ok=counters->number_of_LinphoneRegistrationOk;
number_of_udp_proxy=get_number_of_udp_proxy(lc);
total_number_of_proxies=bctbx_list_size(linphone_core_get_proxy_config_list(lc));
total_number_of_proxies=(int)bctbx_list_size(linphone_core_get_proxy_config_list(lc));
linphone_core_get_sip_transports(lc,&sip_tr_orig);
sip_tr.udp_port=sip_tr_orig.udp_port;
@ -739,7 +739,7 @@ static void io_recv_error_late_recovery(void){
lc=lcm->lc;
sal_set_refresher_retry_after(lc->sal,1000);
counters=&lcm->stat;
BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc))));
BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,(int)bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc))));
counters = get_stats(lc);
@ -791,7 +791,7 @@ static void io_recv_error_without_active_register(void){
/*nothing should happen because no active registration*/
wait_for_until(lc,lc, &dummy, 1, 3000);
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, bctbx_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d");
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, (int)bctbx_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d");
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0,int,"%d");

View file

@ -114,7 +114,7 @@ static void remote_provisioning_file(void) {
marie = linphone_core_manager_new2("marie_remote_localfile_win10_rc", FALSE);
#else
marie = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(marie, "marie_remote_localfile_rc");
linphone_core_manager_init(marie, "marie_remote_localfile_rc",NULL);
// fix relative path to absolute path
{
char* path = bc_tester_res("rcfiles/marie_remote_localfile2_rc");

View file

@ -121,7 +121,7 @@ static void check_turn_context_statistics(MSTurnContext *turn_context, bool_t fo
}
}
static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled) {
static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled, bool_t ipv6) {
LinphoneCoreManager *marie;
LinphoneCoreManager *pauline;
LinphoneCall *lcall;
@ -129,11 +129,16 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t
LinphoneMediaDirection expected_video_dir = LinphoneMediaDirectionInactive;
bctbx_list_t *lcs = NULL;
marie = linphone_core_manager_new("marie_rc");
marie = linphone_core_manager_new2("marie_rc", FALSE);
lcs = bctbx_list_append(lcs, marie->lc);
pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
pauline = linphone_core_manager_new2(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc", FALSE);
lcs = bctbx_list_append(lcs, pauline->lc);
if (ipv6) {
linphone_core_enable_ipv6(marie->lc, TRUE);
linphone_core_enable_ipv6(pauline->lc, TRUE);
}
configure_nat_policy(marie->lc, caller_turn_enabled);
configure_nat_policy(pauline->lc, callee_turn_enabled);
if (forced_relay == TRUE) {
@ -148,6 +153,9 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t
lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1);
}
linphone_core_manager_start(marie, TRUE);
linphone_core_manager_start(pauline, TRUE);
if (video_enabled) {
#ifdef VIDEO_ENABLED
video_call_base_2(marie, pauline, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE);
@ -184,31 +192,39 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t
}
static void basic_ice_turn_call(void) {
ice_turn_call_base(FALSE, FALSE, TRUE, TRUE, FALSE);
ice_turn_call_base(FALSE, FALSE, TRUE, TRUE, FALSE, FALSE);
}
static void basic_ipv6_ice_turn_call(void) {
if (liblinphone_tester_ipv6_available()) {
ice_turn_call_base(FALSE, FALSE, TRUE, TRUE, FALSE, TRUE);
} else {
ms_warning("Test skipped, no ipv6 available");
}
}
#ifdef VIDEO_ENABLED
static void video_ice_turn_call(void) {
ice_turn_call_base(TRUE, FALSE, TRUE, TRUE, FALSE);
ice_turn_call_base(TRUE, FALSE, TRUE, TRUE, FALSE, FALSE);
}
#endif
static void relayed_ice_turn_call(void) {
ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, FALSE);
ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, FALSE, FALSE);
}
#ifdef VIDEO_ENABLED
static void relayed_video_ice_turn_call(void) {
ice_turn_call_base(TRUE, TRUE, TRUE, TRUE, FALSE);
ice_turn_call_base(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE);
}
#endif
static void relayed_ice_turn_call_with_rtcp_mux(void) {
ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, TRUE);
ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, TRUE, FALSE);
}
static void relayed_ice_turn_to_ice_stun_call(void) {
ice_turn_call_base(FALSE, TRUE, TRUE, FALSE, FALSE);
ice_turn_call_base(FALSE, TRUE, TRUE, FALSE, FALSE, FALSE);
}
@ -216,6 +232,7 @@ test_t stun_tests[] = {
TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"),
TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"),
TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"),
TEST_TWO_TAGS("Basic IPv6 ICE+TURN call", basic_ipv6_ice_turn_call, "ICE", "TURN"),
#ifdef VIDEO_ENABLED
TEST_TWO_TAGS("Video ICE+TURN call", video_ice_turn_call, "ICE", "TURN"),
TEST_TWO_TAGS("Relayed video ICE+TURN call", relayed_video_ice_turn_call, "ICE", "TURN"),

View file

@ -266,7 +266,7 @@ bool_t transport_supported(LinphoneTransportType transport) {
bool_t supported = sal_transport_available(sal,(SalTransport)transport);
if (!supported) ms_message("TLS transport not supported, falling back to TCP if possible otherwise skipping test.");
sal_uninit(sal);
return supported;
return 0 & supported;
}
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
@ -277,7 +277,7 @@ bool_t transport_supported(LinphoneTransportType transport) {
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) {
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, const char* phone_alias) {
char *rc_path = NULL;
char *hellopath = bc_tester_res("sounds/hello8000.wav");
mgr->number_of_bcunit_error_at_creation = bc_get_number_of_failures();
@ -300,6 +300,8 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) {
mgr->v_table.dtmf_received=dtmf_received;
mgr->v_table.call_stats_updated=call_stats_updated;
mgr->phone_alias = phone_alias ? ms_strdup(phone_alias) : NULL;
reset_counters(&mgr->stat);
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
mgr->lc=configure_lc_from(&mgr->v_table, bc_tester_get_resource_dir_prefix(), rc_path, mgr);
@ -358,7 +360,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
/*BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/
if (check_for_proxies){ /**/
proxy_count=bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc));
proxy_count=(int)bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc));
}else{
proxy_count=0;
/*this is to prevent registration to go on*/
@ -390,22 +392,28 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
/*now that stun server resolution is done, we can start registering*/
linphone_core_set_network_reachable(mgr->lc, TRUE);
}
}
LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) {
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) {
int old_log_level = ortp_get_log_level_mask(NULL);
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(manager, rc_file);
linphone_core_manager_start(manager, TRUE);
linphone_core_set_log_level(ORTP_ERROR);
linphone_core_manager_init(manager, rc_file, phone_alias);
linphone_core_manager_start(manager, check_for_proxies);
linphone_core_set_log_level(old_log_level);
return manager;
}
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies) {
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(manager, rc_file);
linphone_core_manager_start(manager, check_for_proxies);
return manager;
return linphone_core_manager_new3(rc_file, check_for_proxies, NULL);
}
LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) {
return linphone_core_manager_new2(rc_file, TRUE);
}
void linphone_core_manager_stop(LinphoneCoreManager *mgr){
if (mgr->lc) {
linphone_core_destroy(mgr->lc);
@ -414,6 +422,11 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){
}
void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
int old_log_level = ortp_get_log_level_mask(NULL);
linphone_core_set_log_level(ORTP_ERROR);
if (mgr->phone_alias) {
ms_free(mgr->phone_alias);
}
if (mgr->stat.last_received_chat_message) {
linphone_chat_message_unref(mgr->stat.last_received_chat_message);
}
@ -423,7 +436,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
char *chatdb = ms_strdup(linphone_core_get_chat_database_path(mgr->lc));
if (!liblinphone_tester_keep_record_files && record_file){
if ((bc_get_number_of_failures()-mgr->number_of_bcunit_error_at_creation)>0) {
ms_message ("Test has failed, keeping recorded file [%s]",record_file);
ms_error("Test has failed, keeping recorded file [%s]",record_file);
} else {
unlink(record_file);
}
@ -439,6 +452,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
}
manager_count--;
linphone_core_set_log_level(old_log_level);
}
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr) {
@ -656,20 +670,33 @@ static void check_ice_from_rtp(LinphoneCall *c1, LinphoneCall *c2, LinphoneStrea
return;
}
if (linphone_call_get_audio_stats(c1)->ice_state == LinphoneIceStateHostConnection && media_stream_started(ms)) {
char ip[16];
char port[8];
getnameinfo((const struct sockaddr *)&c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addr
, c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addrlen
, ip
, sizeof(ip)
, port
, sizeof(port)
, NI_NUMERICHOST|NI_NUMERICSERV);
BC_ASSERT_STRING_EQUAL(ip, c2->media_localip);
struct sockaddr_storage remaddr;
socklen_t remaddrlen = sizeof(remaddr);
char ip[NI_MAXHOST] = { 0 };
int port = 0;
SalMediaDescription *result_desc;
char *expected_addr = NULL;
const LinphoneCallParams *cp1 = linphone_call_get_current_params(c1);
const LinphoneCallParams *cp2 = linphone_call_get_current_params(c2);
if (cp1->update_call_when_ice_completed && cp2->update_call_when_ice_completed) {
memset(&remaddr, 0, remaddrlen);
result_desc = sal_call_get_final_media_description(c2->op);
expected_addr = result_desc->streams[0].rtp_addr;
if (expected_addr[0] == '\0') expected_addr = result_desc->addr;
if ((strchr(expected_addr, ':') == NULL) && (c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addr.ss_family == AF_INET6)) {
bctbx_sockaddr_ipv6_to_ipv4((struct sockaddr *)&c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addr, (struct sockaddr *)&remaddr, &remaddrlen);
} else {
memcpy(&remaddr, &c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addr, c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addrlen);
}
bctbx_sockaddr_to_ip_address((struct sockaddr *)&remaddr, remaddrlen, ip, sizeof(ip), &port);
BC_ASSERT_STRING_EQUAL(ip, expected_addr);
}
}
}
bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) {
LinphoneCall *c1,*c2;
bool_t audio_success=FALSE;
@ -826,7 +853,7 @@ LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bo
conf_srv->vtable->registration_state_changed = linphone_conference_server_registration_state_changed;
conf_srv->vtable->user_data = conf_srv;
conf_srv->reg_state = LinphoneRegistrationNone;
linphone_core_manager_init(lm, rc_file);
linphone_core_manager_init(lm, rc_file,NULL);
linphone_core_add_listener(lm->lc, conf_srv->vtable);
linphone_core_manager_start(lm, do_registration);
return conf_srv;

View file

@ -138,7 +138,7 @@ static void linphone_vcard_update_existing_friends_test(void) {
static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf);
bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf);
@ -150,7 +150,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
if (phone_numbers) bctbx_list_free(phone_numbers);
linphone_friend_unref(lf);
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
lf = linphone_friend_new_from_vcard(lvc);
sip_addresses = linphone_friend_get_addresses(lf);
phone_numbers = linphone_friend_get_phone_numbers(lf);
@ -473,7 +473,7 @@ static void carddav_sync_2(void) {
static void carddav_sync_3(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
char *friends_db = bc_tester_file("friends.db");
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
@ -514,7 +514,7 @@ static void carddav_sync_3(void) {
static void carddav_sync_4(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
@ -575,7 +575,7 @@ static void carddav_sync_status_changed(LinphoneFriendList *list, LinphoneFriend
static void carddav_integration(void) {
LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
LinphoneVcard *lvc2 = NULL;
LinphoneFriend *lf2 = NULL;
@ -608,12 +608,12 @@ static void carddav_integration(void) {
linphone_friend_unref(lf);
lf = NULL;
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
lf = linphone_friend_new_from_vcard(lvc);
BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d");
linphone_friend_unref(lf);
lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf");
lf2 = linphone_friend_new_from_vcard(lvc2);
linphone_friend_set_ref_key(lf2, refkey);
@ -691,7 +691,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
}
bctbx_list_free(friends);
lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
lf = linphone_friend_new_from_vcard(lvc);
linphone_friend_list_add_friend(lfl, lf);
@ -739,9 +739,9 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
LinphoneVcard *lvc1 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc1 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1);
LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneVcard *lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n");
LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2);
bctbx_list_t *friends = NULL, *friends_iterator = NULL;

51
tools/lpconfig_items.py Normal file
View file

@ -0,0 +1,51 @@
#!/usr/bin/python
from collections import defaultdict
items = defaultdict(list)
def get_files_in_coreapi_directory():
from os import walk
files = []
for (dirpath, dirnames, filenames) in walk('../coreapi'):
files.extend(filenames)
break
return files
def parse_file(filename):
with open('../coreapi/' + filename, 'r') as infile:
for line in infile:
if 'lp_config_get_' in line:
parse_lpconfig_line(line)
def parse_lpconfig_line(line):
token = line[line.find('lp_config_get_') + len('lp_config_get_'):]
split = token.split('(', 1)
item_type = split[0]
if '_' in item_type:
return
params_split = split[1].split(',', 3)
item_section = params_split[1]
if item_section[0] != '"':
return
item_section = item_section.split('"')[1]
item_name = params_split[2]
if item_name[0] != '"':
return
item_name = item_name.split('"')[1]
item_default_value = params_split[3].split(')')[0]
if item_type == 'string' and item_default_value[0] != '"':
item_default_value = '<unknown_string>'
item = [item_type, item_name, item_default_value]
items[item_section].append(item)
for files in get_files_in_coreapi_directory():
parse_file(files)
for section, items in items.iteritems():
print '[' + section + ']'
for item in items:
print item[1] + '=' + item[2]
print ''