Commit 8d21c03f authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI
Browse files

Merge branch 'ldap'

parents ffaf9682 b560f773
......@@ -165,6 +165,24 @@ AC_ARG_ENABLE(x11,
[enable_x11=true]
)
dnl conditional build of LDAP support
AC_ARG_ENABLE(ldap,
[AS_HELP_STRING([--disable-ldap], [Disable LDAP support (default=no)])],
[case "${enableval}" in
yes) enable_ldap=true ;;
no) enable_ldap=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-ldap) ;;
esac],
[enable_ldap=true]
)
AM_CONDITIONAL(BUILD_LDAP, test x$enable_ldap != xfalse)
if test "$enable_ldap" = "true"; then
AC_CHECK_LIB(ldap,ldap_initialize, LDAP_LIBS="-lldap")
AC_SUBST(LDAP_LIBS)
AC_DEFINE(BUILD_LDAP,1,[Defined if LDAP build option enabled])
fi
dnl conditionnal build of console interface.
AC_ARG_ENABLE(console_ui,
[AS_HELP_STRING([--enable-console_ui=[yes/no]], [Turn on or off compilation of console interface (default=yes)])],
......@@ -864,6 +882,7 @@ printf "* %-30s %s\n" "Tools" $build_tools
printf "* %-30s %s\n" "Message storage" $enable_msg_storage
printf "* %-30s %s\n" "zRTP encryption (GPLv3)" $zrtp
printf "* %-30s %s\n" "uPnP support" $build_upnp
printf "* %-30s %s\n" "LDAP support" $enable_ldap
if test "$enable_tunnel" = "true" ; then
printf "* %-30s %s\n" "Tunnel support" "true"
......
......@@ -24,11 +24,12 @@ bin_PROGRAMS+=linphoned
endif
linphonec_SOURCES=linphonec.c linphonec.h commands.c
linphonec_CFLAGS=$(COMMON_CFLAGS) $(CONSOLE_FLAGS)
linphonec_CFLAGS=$(COMMON_CFLAGS) $(CONSOLE_FLAGS) $(BELLESIP_CFLAGS)
linphonec_LDADD=$(top_builddir)/coreapi/liblinphone.la \
$(READLINE_LIBS) \
$(SQLITE3_LIBS) \
$(X11_LIBS)
$(X11_LIBS) \
$(BELLESIP_LIBS)
if BUILD_WIN32
#special build of linphonec to detach from the windows console
......
......@@ -48,11 +48,17 @@ liblinphone_la_SOURCES=\
message_storage.c \
info.c \
event.c event.h \
contactprovider.c contactprovider.h \
dict.c \
$(GITVERSION_FILE)
if BUILD_UPNP
liblinphone_la_SOURCES+=upnp.c upnp.h
endif
if BUILD_LDAP
liblinphone_la_SOURCES+= ldap/ldapprovider.c ldap/ldapprovider.h
endif
liblinphone_la_SOURCES+= bellesip_sal/sal_address_impl.c \
bellesip_sal/sal_impl.c bellesip_sal/sal_impl.h \
......@@ -104,7 +110,8 @@ liblinphone_la_LIBADD= \
$(TUNNEL_LIBS) \
$(LIBSOUP_LIBS) \
$(SQLITE3_LIBS) \
$(LIBXML2_LIBS)
$(LIBXML2_LIBS) \
$(LDAP_LIBS)
if ENABLE_TESTS
......
/*
* 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 Library 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 "contactprovider.h"
#include <linphonecore.h>
/* LinphoneContactSearchRequest
*/
void linphone_contact_search_init(LinphoneContactSearch* obj,
const char* predicate,
ContactSearchCallback cb,
void* cb_data)
{
static unsigned int request_id_counter = 1;
obj->id = request_id_counter++; // unique id
obj->predicate = ms_strdup(predicate?predicate:"");
obj->cb = cb;
obj->data = cb_data;
ms_message("LinphoneContactSearch@%p(id:%d, pred:%s, cb:%p, data:%p)",
obj, obj->id, obj->predicate, obj->cb, obj->data);
}
static void linphone_contact_search_destroy( LinphoneContactSearch* req) {
ms_message( "~LinphoneContactSearch(%p)", req);
if( req->predicate ) ms_free(req->predicate);
}
ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj)
{
return obj->id;
}
const char*linphone_contact_search_get_predicate(LinphoneContactSearch* obj)
{
return obj->predicate;
}
void linphone_contact_search_invoke_cb(LinphoneContactSearch* req, MSList* friends)
{
if( req->cb ) req->cb(req, friends, req->data);
}
int linphone_contact_search_compare(const void* a, const void* b) {
LinphoneContactSearch *ra=((LinphoneContactSearch*)a);
LinphoneContactSearch *rb=((LinphoneContactSearch*)b);
return !(ra->id == rb->id); // return 0 if id is equal, 1 otherwise
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneContactSearch);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneContactSearch,belle_sip_object_t,
(belle_sip_object_destroy_t)linphone_contact_search_destroy,
NULL, // clone
NULL, // marshal
FALSE
);
/*
* LinphoneContactProvider
*/
void linphone_contact_provider_init(LinphoneContactProvider* obj, LinphoneCore* lc){
obj->lc = lc;
}
static void contact_provider_destroy(LinphoneContactProvider* obj){
(void)obj;
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneContactProvider);
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR(LinphoneContactProvider)=
{
{
BELLE_SIP_VPTR_INIT(LinphoneContactProvider,belle_sip_object_t,TRUE),
(belle_sip_object_destroy_t) contact_provider_destroy,
NULL,/*no clone*/
NULL,/*no marshal*/
},
"",
// Pure virtual
NULL, /* begin_search -> pure virtual */
NULL /* cancel_search -> pure virtual */
};
/*
* 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 Library 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 <belle-sip/object.h>
#include "linphonecore.h"
/* LinphoneContactSearchRequest */
struct _LinphoneContactSearch{
belle_sip_object_t base;
ContactSearchID id;
char* predicate;
ContactSearchCallback cb;
void* data;
};
#define LINPHONE_CONTACT_SEARCH(obj) BELLE_SIP_CAST(obj,LinphoneContactSearch)
BELLE_SIP_DECLARE_VPTR(LinphoneContactSearch)
void linphone_contact_search_init(LinphoneContactSearch* obj, const char* predicate, ContactSearchCallback cb, void* cb_data);
ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj);
const char* linphone_contact_search_get_predicate(LinphoneContactSearch* obj);
void linphone_contact_search_invoke_cb(LinphoneContactSearch* req, MSList* friends);
/* LinphoneContactProvider */
struct _LinphoneContactProvider {
belle_sip_object_t base;
LinphoneCore* lc;
};
typedef struct _LinphoneContactProvider LinphoneContactProvider;
typedef LinphoneContactSearch* (*LinphoneContactProviderStartSearchMethod)( LinphoneContactProvider* thiz, const char* predicate, ContactSearchCallback cb, void* data );
typedef unsigned int (*LinphoneContactProviderCancelSearchMethod)( LinphoneContactProvider* thiz, LinphoneContactSearch *request );
#define LINPHONE_CONTACT_PROVIDER(obj) BELLE_SIP_CAST(obj,LinphoneContactProvider)
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(LinphoneContactProvider,belle_sip_object_t)
const char* name; /*!< Name of the contact provider (LDAP, Google, ...) */
/* pure virtual methods: inheriting objects must implement these */
LinphoneContactProviderStartSearchMethod begin_search;
LinphoneContactProviderCancelSearchMethod cancel_search;
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
void linphone_contact_provider_init(LinphoneContactProvider* obj, LinphoneCore* lc);
LinphoneCore* linphone_contact_provider_get_core(LinphoneContactProvider* obj);
const char* linphone_contact_provider_get_name(LinphoneContactProvider* obj);
/*
linphone
Copyright (C) 2009 Simon MORLAT (simon.morlat@linphone.org)
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 "linphonecore.h"
#include "lpconfig.h"
#include "private.h"
#include <belle-sip/belle-sip.h>
#include <belle-sip/object.h>
#include <belle-sip/dict.h>
/**
* @addtogroup linphone_dict
* @{
**/
LinphoneDictionary* linphone_dictionary_new()
{
return belle_sip_dict_create();
}
LinphoneDictionary* linphone_dictionary_clone(const LinphoneDictionary* src)
{
LinphoneDictionary* cloned = linphone_dictionary_new();
if( cloned ){
belle_sip_dict_clone(src, cloned);
}
return cloned;
}
LinphoneDictionary* linphone_dictionary_ref(LinphoneDictionary* obj)
{
return BELLE_SIP_DICT(belle_sip_object_ref(obj));
}
void linphone_dictionary_unref(LinphoneDictionary *obj)
{
belle_sip_object_unref(obj);
}
void linphone_dictionary_set_int(LinphoneDictionary* obj, const char* key, int value)
{
belle_sip_dict_set_int(obj, key, value);
}
int linphone_dictionary_get_int(LinphoneDictionary* obj, const char* key, int default_value)
{
return belle_sip_dict_get_int(obj, key, default_value);
}
void linphone_dictionary_set_string(LinphoneDictionary* obj, const char* key, const char*value)
{
belle_sip_dict_set_string(obj, key, value);
}
const char* linphone_dictionary_get_string(LinphoneDictionary* obj, const char* key, const char* default_value)
{
return belle_sip_dict_get_string(obj, key, default_value);
}
void linphone_dictionary_set_int64(LinphoneDictionary* obj, const char* key, int64_t value)
{
belle_sip_dict_set_int64(obj, key, value);
}
int64_t linphone_dictionary_get_int64(LinphoneDictionary* obj, const char* key, int64_t default_value)
{
return belle_sip_dict_get_int64(obj, key, default_value);
}
int linphone_dictionary_remove(LinphoneDictionary* obj, const char* key)
{
return belle_sip_dict_remove(obj, key);
}
void linphone_dictionary_clear(LinphoneDictionary* obj)
{
belle_sip_dict_clear(obj);
}
int linphone_dictionary_haskey(const LinphoneDictionary* obj, const char* key)
{
return belle_sip_dict_haskey(obj, key);
}
void linphone_dictionary_foreach(const LinphoneDictionary* obj, void (*apply_func)(const char*, void*, void*), void* userdata)
{
return belle_sip_dict_foreach(obj, apply_func, userdata);
}
struct lp_config_to_dict {
const char* section;
const LpConfig* config;
LinphoneDictionary* dict;
};
static void lp_config_section_to_dict_cb(const char*key, struct lp_config_to_dict* userdata)
{
const char* value = lp_config_get_string(userdata->config, userdata->section, key, "");
linphone_dictionary_set_string(userdata->dict, key, value);
}
LinphoneDictionary* lp_config_section_to_dict(const LpConfig* lpconfig, const char* section)
{
LinphoneDictionary* dict = NULL;
struct lp_config_to_dict fd;
fd.config = lpconfig;
fd.section = section;
dict = linphone_dictionary_new();
fd.dict = dict;
lp_config_for_each_entry(lpconfig, section,
(void (*)(const char*, void*))lp_config_section_to_dict_cb,
&fd);
return dict;
}
struct lp_config_from_dict {
const char* section;
LpConfig* config;
};
static void lp_config_dict_dump_cb( const char* key, void* value, void* userdata)
{
struct lp_config_from_dict* fd= (struct lp_config_from_dict*)userdata;
lp_config_set_string(fd->config, fd->section, key, (const char*)value);
}
void lp_config_load_dict_to_section(LpConfig* lpconfig, const char* section, const LinphoneDictionary* dict)
{
struct lp_config_from_dict pvdata = { section, lpconfig };
linphone_dictionary_foreach(dict,lp_config_dict_dump_cb, &pvdata);
}
/**
* @}
**/
......@@ -53,7 +53,8 @@ LINPHONE_TUTOS=$(helloworld_SOURCES)
helloworld_LDADD=$(top_builddir)/coreapi/liblinphone.la \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS)
$(ORTP_LIBS) \
$(BELLESIP_LIBS)
registration_SOURCES=registration.c
LINPHONE_TUTOS+=$(registration_SOURCES)
......@@ -85,7 +86,8 @@ AM_CFLAGS=\
-DLOG_DOMAIN=\"LinphoneCore\" \
$(IPV6_CFLAGS) \
-DORTP_INET6 \
$(VIDEO_CFLAGS)
$(VIDEO_CFLAGS) \
$(BELLESIP_CFLAGS)
tutodir=$(datadir)/tutorials/linphone
......
This diff is collapsed.
/*
* 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 Library 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 "contactprovider.h"
#include <ldap.h>
typedef struct _LinphoneLDAPContactProvider LinphoneLDAPContactProvider;
/* LinphoneLDAPContactSearch */
typedef struct _LinphoneLDAPContactSearch LinphoneLDAPContactSearch;
#define LINPHONE_LDAP_CONTACT_SEARCH(obj) BELLE_SIP_CAST(obj,LinphoneLDAPContactSearch)
BELLE_SIP_DECLARE_VPTR(LinphoneLDAPContactSearch)
LinphoneLDAPContactSearch* linphone_ldap_contact_search_create(LinphoneLDAPContactProvider* ld,
const char* predicate,
ContactSearchCallback cb,
void* cb_data);
unsigned int linphone_ldap_contact_search_result_count(LinphoneLDAPContactSearch* obj);
/* LinphoneLDAPContactProvider */
#define LINPHONE_LDAP_CONTACT_PROVIDER(obj) BELLE_SIP_CAST(obj,LinphoneLDAPContactProvider)
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(LinphoneLDAPContactProvider,LinphoneContactProvider)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
LinphoneLDAPContactProvider* linphone_ldap_contact_provider_create(LinphoneCore* lc, const LinphoneDictionary* config);
unsigned int linphone_ldap_contact_provider_get_max_result(const LinphoneLDAPContactProvider* obj);
......@@ -1350,6 +1350,7 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
lc->tunnel=linphone_core_tunnel_new(lc);
if (lc->tunnel) linphone_tunnel_configure(lc->tunnel);
#endif
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
......@@ -5674,16 +5675,23 @@ static void linphone_core_uninit(LinphoneCore *lc)
}
#endif //BUILD_UPNP
#ifdef BUILD_LDAP
if( lc->ldap != NULL ) {
belle_sip_object_unref(lc->ldap);
lc->ldap = NULL;
}
#endif
if (lp_config_needs_commit(lc->config)) lp_config_sync(lc->config);
lp_config_destroy(lc->config);
lc->config = NULL; /* Mark the config as NULL to block further calls */
ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_destroy);
lc->call_logs=ms_list_free(lc->call_logs);
ms_list_for_each(lc->last_recv_msg_ids,ms_free);
lc->last_recv_msg_ids=ms_list_free(lc->last_recv_msg_ids);
// Free struct variable
if(lc->zrtp_secrets_cache != NULL) {
ms_free(lc->zrtp_secrets_cache);
......@@ -6287,5 +6295,3 @@ void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path){
linphone_core_message_storage_init(lc);
}
}
......@@ -32,6 +32,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "lpconfig.h"
#include <belle-sip/object.h>
#include <belle-sip/dict.h>
#define LINPHONE_IPADDR_SIZE 64
#define LINPHONE_HOSTNAME_SIZE 128
......@@ -118,6 +121,8 @@ typedef enum _LinphoneTransportType LinphoneTransportType;
*/
typedef struct SalAddress LinphoneAddress;
typedef struct belle_sip_dict LinphoneDictionary;
/**
* The LinphoneContent struct holds data that can be embedded in a signaling message.
* @ingroup misc
......@@ -181,6 +186,37 @@ typedef enum _LinphoneReason LinphoneReason;
**/
const char *linphone_reason_to_string(LinphoneReason err);
/* linphone dictionary */
LINPHONE_PUBLIC LinphoneDictionary* linphone_dictionary_new();
LinphoneDictionary * linphone_dictionary_clone(const LinphoneDictionary* src);
LinphoneDictionary * linphone_dictionary_ref(LinphoneDictionary* obj);
void linphone_dictionary_unref(LinphoneDictionary* obj);
LINPHONE_PUBLIC void linphone_dictionary_set_int(LinphoneDictionary* obj, const char* key, int value);
LINPHONE_PUBLIC int linphone_dictionary_get_int(LinphoneDictionary* obj, const char* key, int default_value);
LINPHONE_PUBLIC void linphone_dictionary_set_string(LinphoneDictionary* obj, const char* key, const char*value);
LINPHONE_PUBLIC const char* linphone_dictionary_get_string(LinphoneDictionary* obj, const char* key, const char* default_value);
LINPHONE_PUBLIC void linphone_dictionary_set_int64(LinphoneDictionary* obj, const char* key, int64_t value);
LINPHONE_PUBLIC int64_t linphone_dictionary_get_int64(LinphoneDictionary* obj, const char* key, int64_t default_value);
LINPHONE_PUBLIC int linphone_dictionary_remove(LinphoneDictionary* obj, const char* key);
LINPHONE_PUBLIC void linphone_dictionary_clear(LinphoneDictionary* obj);
LINPHONE_PUBLIC int linphone_dictionary_haskey(const LinphoneDictionary* obj, const char* key);
LINPHONE_PUBLIC void linphone_dictionary_foreach( const LinphoneDictionary* obj, void (*apply_func)(const char*key, void* value, void* userdata), void* userdata);
/**
* Converts a config section into a dictionary.
* @return a #LinphoneDictionary with all the keys from a section, or NULL if the section doesn't exist
* @ingroup misc
*/
LinphoneDictionary* lp_config_section_to_dict( const LpConfig* lpconfig, const char* section );
/**
* Loads a dictionary into a section of the lpconfig. If the section doesn't exist it is created.
* Overwrites existing keys, creates non-existing keys.
* @ingroup misc
*/
void lp_config_load_dict_to_section( LpConfig* lpconfig, const char* section, const LinphoneDictionary* dict);
#ifdef IN_LINPHONE
#include "linphonefriend.h"
#include "event.h"
......@@ -402,7 +438,7 @@ typedef enum _LinphonePrivacy {
*
**/
LinphonePrivacyCritical=0x10,
/**
* Special keyword to use privacy as defined either globally or by proxy using linphone_proxy_config_set_privacy()
*/
......@@ -442,7 +478,7 @@ LINPHONE_PUBLIC LinphoneInfoMessage *linphone_info_message_copy(const LinphoneIn
* @ingroup media_parameters
**/
struct _LinphoneVideoPolicy{
bool_t automatically_initiate; /**<Whether video shall be automatically proposed for outgoing calls.*/
bool_t automatically_initiate; /**<Whether video shall be automatically proposed for outgoing calls.*/
bool_t automatically_accept; /**<Whether video shall be automatically accepted for incoming calls*/
bool_t unused[2];
};
......@@ -901,7 +937,7 @@ struct _LinphoneChatRoom;
* <br> Can be created by linphone_chat_room_create_message().
*/
typedef struct _LinphoneChatMessage LinphoneChatMessage;
/**
* A chat room is the place where text messages are exchanged.
* <br> Can be created by linphone_core_create_chat_room().
......@@ -945,7 +981,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_unread_messages_count(LinphoneChatRoo
LINPHONE_PUBLIC LinphoneCore* linphone_chat_room_get_lc(LinphoneChatRoom *cr);
LINPHONE_PUBLIC void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
LINPHONE_PUBLIC void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);
LINPHONE_PUBLIC MSList* linphone_core_get_chat_rooms(LinphoneCore *lc);
LINPHONE_PUBLIC MSList* linphone_core_get_chat_rooms(LinphoneCore *lc);
LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *msg);
LINPHONE_PUBLIC const char* linphone_chat_message_state_to_string(const LinphoneChatMessageState state);
......@@ -1023,23 +1059,23 @@ typedef void (*LinphoneCoreCallEncryptionChangedCb)(LinphoneCore *lc, LinphoneCa
* Registration state notification callback prototype
* */
typedef void (*LinphoneCoreRegistrationStateChangedCb)(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
/** Callback prototype
* @deprecated
/** Callback prototype
* @deprecated
*/
typedef void (*ShowInterfaceCb)(LinphoneCore *lc);
/** Callback prototype
* @deprecated
/** Callback prototype
* @deprecated
*/
typedef void (*DisplayStatusCb)(LinphoneCore *lc, const char *message);
/** Callback prototype
* @deprecated
/** Callback prototype
* @deprecated
*/
typedef void (*DisplayMessageCb)(LinphoneCore *lc, const char *message);
/** Callback prototype
* @deprecated
/** Callback prototype