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

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);
}
}
This diff is collapsed.
......@@ -74,6 +74,10 @@ extern "C" {
#endif
#endif
#ifdef BUILD_LDAP
#include "ldap/ldapprovider.h"
#endif
struct _LinphoneCallParams{
LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */
int audio_bw; /* bandwidth limit for audio stream */
......@@ -656,6 +660,10 @@ struct _LinphoneCore
#ifdef BUILD_UPNP
UpnpContext *upnp;
#endif //BUILD_UPNP
#ifdef BUILD_LDAP
LinphoneLDAPContactProvider* ldap;
#endif //BUILD_LDAP
};
......
......@@ -55,7 +55,7 @@ linphone_SOURCES+= \
endif
linphone_LDADD= $(top_builddir)/coreapi/liblinphone.la \
$(LIBGTK_LIBS) $(NOTIFY1_LIBS) $(NOTIFY4_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS) $(SQLITE3_LIBS)
$(LIBGTK_LIBS) $(NOTIFY1_LIBS) $(NOTIFY4_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS) $(SQLITE3_LIBS) $(BELLESIP_LIBS)
if BUILD_WIN32
......@@ -77,7 +77,7 @@ endif
AM_CFLAGS= -DIN_LINPHONE -I$(top_srcdir)/coreapi/ \
$(MEDIASTREAMER_CFLAGS) \
$(ORTP_CFLAGS) \
$(ORTP_CFLAGS) $(BELLESIP_CFLAGS) \
$(STRICT_OPTIONS) $(LIBGTK_CFLAGS) $(LIBGTKMAC_CFLAGS) $(IPV6_CFLAGS) \
$(TUNNEL_CFLAGS) \
$(SQLITE3_CFLAGS)
......
......@@ -28,6 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
#include "linphonecore.h"
#ifdef BUILD_LDAP
#include "ldap/ldapprovider.h"
#endif
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
......@@ -46,6 +51,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define LINPHONE_VERSION LINPHONE_VERSION_DATE
#endif
enum {
COMPLETION_HISTORY,
COMPLETION_LDAP
};
GdkPixbuf * create_pixbuf(const gchar *filename);
GdkPixbufAnimation *create_pixbuf_animation(const gchar *filename);
void add_pixmap_directory(const gchar *directory);
......@@ -63,6 +73,8 @@ void linphone_gtk_show_assistant(void);
void linphone_gtk_close_assistant(void);
LinphoneCore *linphone_gtk_get_core(void);
LinphoneLDAPContactProvider* linphone_gtk_get_ldap(void);
void linphone_gtk_set_ldap(LinphoneLDAPContactProvider* ldap);
GtkWidget *linphone_gtk_get_main_window();
void linphone_gtk_display_something(GtkMessageType type,const gchar *message);
void linphone_gtk_start_call(GtkWidget *button);
......
......@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphone.h"
void linphone_gtk_login_frame_connect_clicked(GtkWidget *button);
void test_button_clicked_cb(GtkWidget *button);
void linphone_gtk_exit_login_frame(void);
enum {
......
......@@ -50,6 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
const char *this_program_ident_string="linphone_ident_string=" LINPHONE_VERSION;
static LinphoneCore *the_core=NULL;
static LinphoneLDAPContactProvider* ldap_provider = NULL;
static GtkWidget *the_ui=NULL;
static void linphone_gtk_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState rs, const char *msg);
......@@ -69,7 +70,7 @@ void linphone_gtk_save_main_window_position(GtkWindow* mw, GdkEvent *event, gpoi
static gboolean linphone_gtk_auto_answer(LinphoneCall *call);
void linphone_gtk_status_icon_set_blinking(gboolean val);
void _linphone_gtk_enable_video(gboolean val);
void linphone_gtk_on_uribar_changed(GtkEditable *uribar, gpointer user_data);
#ifndef HAVE_GTK_OSX
static gint main_window_x=0;
......@@ -231,6 +232,23 @@ static const char *linphone_gtk_get_factory_config_file(){
return _factory_config_file;
}
LinphoneLDAPContactProvider* linphone_gtk_get_ldap(void){
#ifdef BUILD_LDAP
return ldap_provider;
#else
return NULL;
#endif
}
void linphone_gtk_set_ldap(LinphoneLDAPContactProvider* ldap)
{
if( ldap_provider )
belle_sip_object_unref(ldap_provider);
ldap_provider = ldap ? LINPHONE_LDAP_CONTACT_PROVIDER(belle_sip_object_ref( ldap ))
: NULL;
}
static void linphone_gtk_init_liblinphone(const char *config_file,
const char *factory_config_file, const char *db_file) {
LinphoneCoreVTable vtable={0};
......@@ -256,7 +274,16 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL);
//lp_config_set_int(linphone_core_get_config(the_core), "sip", "store_auth_info", 0);
#ifdef BUILD_LDAP
if( lp_config_has_section(linphone_core_get_config(the_core),"ldap") ){
LpConfig* cfg = linphone_core_get_config(the_core);
LinphoneDictionary* ldap_cfg = lp_config_section_to_dict(cfg, "ldap");
linphone_gtk_set_ldap( linphone_ldap_contact_provider_create(the_core, ldap_cfg) );
}
#endif
linphone_core_set_user_agent(the_core,"Linphone", LINPHONE_VERSION);
linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL);
linphone_core_set_zrtp_secrets_file(the_core,secrets_file);
......@@ -279,7 +306,7 @@ GtkWidget *linphone_gtk_get_main_window(){
}
void linphone_gtk_destroy_main_window() {
linphone_gtk_destroy_window(the_ui);
linphone_gtk_destroy_window(the_ui);
the_ui = NULL;
}
......@@ -629,12 +656,31 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){
return TRUE;
}
static gboolean uribar_completion_matchfunc(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data){
char* address = NULL;
gboolean ret = FALSE;
gchar *tmp= NULL;
gtk_tree_model_get(gtk_entry_completion_get_model(completion),iter,0,&address,-1);
tmp = g_utf8_casefold(address,-1);
if (tmp){
if (strstr(tmp,key))
ret=TRUE;
g_free(tmp);
}
if( address)
g_free(address);
return ret;
}
static void load_uri_history(){
GtkEntry *uribar=GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar"));
char key[20];
int i;
GtkEntryCompletion *gep=gtk_entry_completion_new();
GtkListStore *model=gtk_list_store_new(1,G_TYPE_STRING);
GtkListStore *model=gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
for (i=0;;i++){
const char *uri;
snprintf(key,sizeof(key),"uri%i",i);
......@@ -642,14 +688,18 @@ static void load_uri_history(){
if (uri!=NULL) {
GtkTreeIter iter;
gtk_list_store_append(model,&iter);
gtk_list_store_set(model,&iter,0,uri,-1);
gtk_list_store_set(model,&iter,0,uri,1,COMPLETION_HISTORY,-1);
if (i==0) gtk_entry_set_text(uribar,uri);
}
else break;
}
gtk_entry_completion_set_model(gep,GTK_TREE_MODEL(model));
gtk_entry_completion_set_text_column(gep,0);
gtk_entry_completion_set_popup_completion(gep, TRUE);
gtk_entry_completion_set_match_func(gep,uribar_completion_matchfunc, NULL, NULL);
gtk_entry_completion_set_minimum_key_length(gep,3);
gtk_entry_set_completion(uribar,gep);
g_signal_connect (G_OBJECT (uribar), "changed", G_CALLBACK(linphone_gtk_on_uribar_changed), NULL);
}
static void save_uri_history(){
......@@ -697,10 +747,130 @@ static void completion_add_text(GtkEntry *entry, const char *text){
}
/* and prepend it on top of the list */
gtk_list_store_prepend(GTK_LIST_STORE(model),&iter);
gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,text,-1);
gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,text,1,COMPLETION_HISTORY,-1);
save_uri_history();
}
void on_contact_provider_search_results( LinphoneContactSearch* req, MSList* friends, void* data )
{
GtkTreeIter iter;
GtkEntry* uribar = GTK_ENTRY(data);
GtkEntryCompletion* compl = gtk_entry_get_completion(uribar);
GtkTreeModel* model = gtk_entry_completion_get_model(compl);
GtkListStore* list = GTK_LIST_STORE(model);
gboolean valid;
// clear completion list from previous non-history entries
valid = gtk_tree_model_get_iter_first(model,&iter);
while(valid)
{
char* url;
int type;
gtk_tree_model_get(model,&iter, 0,&url, 1,&type, -1);
if (type != COMPLETION_HISTORY) {
valid = gtk_list_store_remove(list, &iter);
} else {
valid = gtk_tree_model_iter_next(model,&iter);
}
if( url ) g_free(url);
if( !valid ) break;
}
// add new non-history related matches
while( friends ){
LinphoneFriend* lf = friends->data;
if( lf ) {
const LinphoneAddress* la = linphone_friend_get_address(lf);