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

Progress commit on LDAP:

- we now create minphone contacts based on what the LDAP query returns,
- added configuration for specifying which LDAP field corresponds to the SIP address and contact name
- fixed some leaks in LDAP data extraction
- modified the completion of the uribar to include LDAP results. We now insert them into the list when available.
parent c17165ac
This diff is collapsed.
......@@ -46,6 +46,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);
......
......@@ -169,7 +169,52 @@ void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){
void test_cb( LinphoneContactSearch* req, MSList* friends, void* data )
{
ms_message("LDAP Search CB received ");
ms_message("LDAP Search CB received:");
GtkEntry* uribar = GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar"));
GtkTreeModel* model = gtk_entry_completion_get_model(gtk_entry_get_completion(uribar));
GtkListStore* list = GTK_LIST_STORE(model);
GtkTreeIter iter;
// clear completion list from previous LDAP completion suggestions
if (!gtk_tree_model_get_iter_first(model,&iter)) return;
do {
int type;
char* url;
bool_t valid = TRUE;
gtk_tree_model_get(model,&iter,1,&type,0,&url,-1);
if (type == COMPLETION_LDAP) {
ms_message("Removing entry for %s", url?url:"NULL");
valid = gtk_list_store_remove(list, &iter);
} else {
ms_message("Keep entry for %s (type %d)", url?url:"NULL", type);
}
if( url ) g_free(url);
if( !valid ) break;
}while(gtk_tree_model_iter_next(model,&iter));
while( friends ){
LinphoneFriend* lf = friends->data;
if( lf ) {
const LinphoneAddress* la = linphone_friend_get_address(lf);
if( la ){
char *addr = linphone_address_as_string(la);
if( addr ){
ms_message("Match: name=%s, addr=%s", linphone_friend_get_name(lf), addr);
gtk_list_store_insert_with_values(list, &iter, -1,
0, addr,
1, COMPLETION_LDAP, -1);
ms_free(addr);
}
}
}
friends = friends->next;
}
gtk_entry_completion_complete(gtk_entry_get_completion(uribar));
}
......@@ -177,7 +222,10 @@ void test_btn_clicked_cb(GtkWidget *button)
{
ms_message("test_button_clicked_cb");
LinphoneCore* core = linphone_gtk_get_core();
linphone_core_ldap_launch_search(core, "mar", test_cb, (void*)0x12345678);
GtkWidget *uri_bar=linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar");
const gchar* pred = gtk_entry_buffer_get_text(gtk_entry_get_buffer((GtkEntry*)uri_bar));
linphone_core_ldap_launch_search(core, pred, test_cb, (void*)0x12345678);
}
void linphone_gtk_internet_kind_changed(GtkWidget *combo){
......
......@@ -629,12 +629,28 @@ 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);
ms_message("In matchFunc(): key=%s, addr=%s",key,address);
tmp = g_utf8_casefold(address,-1);
if (tmp){
if (strstr(tmp,key))
ret=TRUE;
g_free(tmp);
}
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,13 +658,14 @@ 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_match_func(gep,uribar_completion_matchfunc, NULL, NULL);
gtk_entry_set_completion(uribar,gep);
}
......@@ -697,7 +714,7 @@ 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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment