Commit c17165ac authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Progress commit: first ldap search results are now available.

There's a test button in the ui to test a search.
parent a1bbb890
......@@ -30,11 +30,13 @@ void linphone_contact_search_init(LinphoneContactSearch* obj,
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);
ms_free(req);
}
ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj)
......@@ -49,7 +51,7 @@ const char*linphone_contact_search_get_predicate(LinphoneContactSearch* obj)
void linphone_contact_search_invoke_cb(LinphoneContactSearch* req, MSList* friends)
{
if( req->cb ) req->cb(req->id, friends, req->data);
if( req->cb ) req->cb(req, friends, req->data);
}
int linphone_contact_search_compare(const void* a, const void* b) {
......
......@@ -19,16 +19,13 @@
/* LinphoneContactSearchRequest */
typedef unsigned int ContactSearchID;
typedef void (*ContactSearchCallback)( ContactSearchID id, MSList* friends, void* data );
typedef struct {
struct _LinphoneContactSearch{
belle_sip_object_t base;
ContactSearchID id;
char* predicate;
ContactSearchCallback cb;
void* data;
} LinphoneContactSearch;
};
#define LINPHONE_CONTACT_SEARCH(obj) BELLE_SIP_CAST(obj,LinphoneContactSearch)
BELLE_SIP_DECLARE_VPTR(LinphoneContactSearch)
......
This diff is collapsed.
......@@ -1338,6 +1338,12 @@ 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
#ifdef BUILD_LDAP
lc->ldap =linphone_ldap_contact_provider_create(lc);
belle_sip_object_ref( lc->ldap );
#endif
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
......@@ -5634,16 +5640,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);
......@@ -6247,3 +6260,22 @@ void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path){
}
LinphoneContactSearch* linphone_core_ldap_launch_search(LinphoneCore* lc, const char* predicate, ContactSearchCallback cb, void* userdata)
{
if( lc->ldap ){
LinphoneContactProvider* cp = LINPHONE_CONTACT_PROVIDER(lc->ldap);
LinphoneContactSearch* search = BELLE_SIP_OBJECT_VPTR(cp,LinphoneContactProvider)->begin_search(cp, predicate, cb, userdata);
char *desc = belle_sip_object_to_string(cp);
if( desc) {
ms_message("ldap: %s", desc);
ms_free(desc);
}
if(search){
belle_sip_object_ref(search);
return search;
}
}
return NULL;
}
......@@ -2158,6 +2158,15 @@ BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch)
BELLE_SIP_DECLARE_TYPES_END
typedef unsigned int ContactSearchID;
struct _LinphoneContactSearch;
typedef struct _LinphoneContactSearch LinphoneContactSearch;
typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, MSList* friends, void* data );
LINPHONE_PUBLIC LinphoneContactSearch* linphone_core_ldap_launch_search(LinphoneCore* lc, const char* predicate, ContactSearchCallback cb, void* userdata);
#ifdef __cplusplus
}
......
......@@ -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 */
......@@ -655,6 +659,10 @@ struct _LinphoneCore
#ifdef BUILD_UPNP
UpnpContext *upnp;
#endif //BUILD_UPNP
#ifdef BUILD_LDAP
LinphoneLDAPContactProvider* ldap;
#endif //BUILD_LDAP
};
......
......@@ -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 {
......@@ -166,6 +167,19 @@ void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){
linphone_gtk_load_identities();
}
void test_cb( LinphoneContactSearch* req, MSList* friends, void* data )
{
ms_message("LDAP Search CB received ");
}
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);
}
void linphone_gtk_internet_kind_changed(GtkWidget *combo){
int netkind_id=gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
LinphoneCore *lc=linphone_gtk_get_core();
......
......@@ -1063,6 +1063,21 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="test_btn">
<property name="label" translatable="yes">TEST</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="test_btn_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_call">
<property name="can_focus">True</property>
......@@ -1109,6 +1124,12 @@
<property name="position">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -1547,8 +1568,8 @@
</child>
<child>
<object class="GtkButton" id="proxy_refresh_button">
<property name="can_focus">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property>
......@@ -1762,6 +1783,9 @@
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
......
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