From 42d5c77dc6ac720cb6ad1e7119b7b1540dd9a718 Mon Sep 17 00:00:00 2001 From: smorlat Date: Sun, 8 Mar 2009 21:42:44 +0000 Subject: [PATCH] work in progress. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@312 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/authentication.c | 12 ++++++---- linphone/coreapi/linphonecore.h | 4 ++++ linphone/coreapi/proxy.c | 5 +++++ linphone/coreapi/sipsetup.c | 5 ++++- linphone/coreapi/sipsetup.h | 3 ++- linphone/gtk-glade/buddylookup.c | 33 +++++++++++++++++++++++++--- linphone/gtk-glade/buddylookup.glade | 4 +++- linphone/gtk-glade/friendlist.c | 3 ++- linphone/share/C/Makefile.am | 2 +- 9 files changed, 59 insertions(+), 12 deletions(-) diff --git a/linphone/coreapi/authentication.c b/linphone/coreapi/authentication.c index 001a5d58c..ac1636df2 100644 --- a/linphone/coreapi/authentication.c +++ b/linphone/coreapi/authentication.c @@ -137,7 +137,7 @@ static int auth_info_compare_only_realm(const void *pinfo,const void *pref){ } -LinphoneAuthInfo *linphone_core_auth_info_find(LinphoneCore *lc, const char *realm, const char *username) +LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username) { LinphoneAuthInfo ref; MSList *elem; @@ -198,6 +198,10 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info){ } +const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc){ + return lc->auth_info; +} + void linphone_core_clear_all_auth_info(LinphoneCore *lc){ MSList *elem; int i; @@ -235,9 +239,9 @@ void linphone_authentication_ok(LinphoneCore *lc, eXosip_event_t *ev){ } /* see if we already have this auth information , not to ask it everytime to the user */ if (prx_realm!=NULL) - as=linphone_core_auth_info_find(lc,prx_realm,username); + as=linphone_core_find_auth_info(lc,prx_realm,username); if (www_realm!=NULL) - as=linphone_core_auth_info_find(lc,www_realm,username); + as=linphone_core_find_auth_info(lc,www_realm,username); if (as){ ms_message("Authentication for user=%s realm=%s is working.",username,prx_realm ? prx_realm : www_realm); as->works=TRUE; @@ -247,7 +251,7 @@ void linphone_authentication_ok(LinphoneCore *lc, eXosip_event_t *ev){ void linphone_core_find_or_ask_for_auth_info(LinphoneCore *lc,const char *username,const char* realm, int tid) { - LinphoneAuthInfo *as=linphone_core_auth_info_find(lc,realm,username); + LinphoneAuthInfo *as=linphone_core_find_auth_info(lc,realm,username); if ( as==NULL || (as!=NULL && as->works==FALSE && as->first_time==FALSE)){ if (lc->vtable.auth_info_requested!=NULL){ lc->vtable.auth_info_requested(lc,realm,username); diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index 9fe32b495..8978dedf6 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -599,6 +599,10 @@ void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info); void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info); +const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc); + +LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username); + void linphone_core_abort_authentication(LinphoneCore *lc, LinphoneAuthInfo *info); void linphone_core_clear_all_auth_info(LinphoneCore *lc); diff --git a/linphone/coreapi/proxy.c b/linphone/coreapi/proxy.c index b656519d8..e5c149033 100644 --- a/linphone/coreapi/proxy.c +++ b/linphone/coreapi/proxy.c @@ -44,6 +44,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ if (obj->reg_identity!=NULL) ms_free(obj->reg_identity); if (obj->reg_route!=NULL) ms_free(obj->reg_route); if (obj->ssctx!=NULL) sip_setup_context_free(obj->ssctx); + if (obj->type!=NULL) ms_free(obj->type); } bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj){ @@ -563,9 +564,13 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config return cfg; } + void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){ SipSetup *ss=sip_setup_lookup(type); SipSetupContext *ssc; + if (cfg->type) + ms_free(cfg->type); + cfg->type=ms_strdup(type); if (!ss) return ; ssc=sip_setup_context_new(ss,cfg); if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL)==0){ diff --git a/linphone/coreapi/sipsetup.c b/linphone/coreapi/sipsetup.c index 3b8fd1451..16cd674b1 100644 --- a/linphone/coreapi/sipsetup.c +++ b/linphone/coreapi/sipsetup.c @@ -61,7 +61,7 @@ SipSetup *sip_setup_lookup(const char *type_name){ MSList *elem; for(elem=registered_sip_setups;elem!=NULL;elem=elem->next){ SipSetup *ss=(SipSetup*)elem->data; - if ( strcmp(ss->name,type_name)==0){ + if ( strcasecmp(ss->name,type_name)==0){ if (!ss->initialized){ ss->init(); ss->initialized=TRUE; @@ -166,5 +166,8 @@ void sip_setup_context_free_results(MSList *results){ } void sip_setup_context_free(SipSetupContext *ctx){ + if (ctx->funcs->uninit_instance){ + ctx->funcs->uninit_instance(ctx); + } ms_free(ctx); } diff --git a/linphone/coreapi/sipsetup.h b/linphone/coreapi/sipsetup.h index cf1c11eb2..1a038c629 100644 --- a/linphone/coreapi/sipsetup.h +++ b/linphone/coreapi/sipsetup.h @@ -73,7 +73,7 @@ struct _SipSetup{ char *name; unsigned int capabilities; bool_t (*init)(void); - int (*init_instance)(SipSetupContext *ctx); + void (*init_instance)(SipSetupContext *ctx); int (*create_account)( const char *uri, const char *passwd); int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd); int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); @@ -82,6 +82,7 @@ struct _SipSetup{ int (*lookup_buddy)(SipSetupContext *ctx, const char *key); BuddyLookupStatus (*get_buddy_lookup_status)(SipSetupContext *ctx); int (*get_buddy_lookup_results)(SipSetupContext *ctx, MSList **results); + void (*uninit_instance)(SipSetupContext *ctx); void (*exit)(void); bool_t initialized; }; diff --git a/linphone/gtk-glade/buddylookup.c b/linphone/gtk-glade/buddylookup.c index 02f2d2caf..bb24ca9df 100644 --- a/linphone/gtk-glade/buddylookup.c +++ b/linphone/gtk-glade/buddylookup.c @@ -30,6 +30,7 @@ enum { }; void linphone_gtk_buddy_lookup_window_destroyed(GtkWidget *w){ + g_message("BuddyLookup window is destroyed !"); guint tid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"typing_timeout")); if (tid!=0){ g_source_remove(tid); @@ -48,7 +49,7 @@ void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx){ GtkTreeSelection *select; GtkWidget *w=linphone_gtk_create_window("buddylookup"); GtkWidget *results=linphone_gtk_get_widget(w,"search_results"); - + GtkProgressBar *pb=GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")); store = gtk_list_store_new(LOOKUP_RESULT_NCOL, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); @@ -75,7 +76,10 @@ void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx){ gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(results),LOOKUP_RESULT_ADDRESS); g_object_set_data(G_OBJECT(w),"SipSetupContext",ctx); - g_object_weak_ref(G_OBJECT(w),(GWeakNotify)linphone_gtk_buddy_lookup_window_destroyed,w); + //g_object_weak_ref(G_OBJECT(w),(GWeakNotify)linphone_gtk_buddy_lookup_window_destroyed,w); + g_signal_connect_swapped(G_OBJECT(results),"destroy",(GCallback)linphone_gtk_buddy_lookup_window_destroyed,w); + gtk_progress_bar_set_fraction(pb,0); + gtk_progress_bar_set_text(pb,NULL); gtk_widget_show(w); } @@ -126,7 +130,7 @@ static gboolean keyword_typing_finished(GtkWidget *w){ if (tid!=0){ g_source_remove(tid); } - keyword=gtk_entry_get_text(GTK_ENTRY(w)); + keyword=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"keyword"))); if (strlen(keyword)>=4){ guint tid2; ctx=(SipSetupContext*)g_object_get_data(G_OBJECT(w),"SipSetupContext"); @@ -167,3 +171,26 @@ static void linphone_gtk_display_lookup_results(GtkWidget *w, const MSList *resu } } +void linphone_gtk_add_buddy_from_database(GtkWidget *button){ + GtkWidget *w=gtk_widget_get_toplevel(button); + GtkTreeSelection *select; + GtkTreeIter iter; + GtkTreeModel *model; + select = gtk_tree_view_get_selection(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"search_results"))); + if (gtk_tree_selection_get_selected (select, &model, &iter)) + { + char *uri; + char *name; + char *addr; + LinphoneFriend *lf; + gtk_tree_model_get (model, &iter,LOOKUP_RESULT_SIP_URI , &uri,LOOKUP_RESULT_NAME, &name -1); + addr=g_strdup_printf("%s <%s>",name,uri); + lf=linphone_friend_new_with_addr(addr); + g_free(addr); + g_free(uri); + g_free(name); + linphone_gtk_show_contact(lf); + } +} + + diff --git a/linphone/gtk-glade/buddylookup.glade b/linphone/gtk-glade/buddylookup.glade index 28ce7dae6..7a278ef17 100644 --- a/linphone/gtk-glade/buddylookup.glade +++ b/linphone/gtk-glade/buddylookup.glade @@ -1,6 +1,6 @@ - + Search people... @@ -36,6 +36,8 @@ GTK_SHADOW_ETCHED_IN + 300 + 140 True True diff --git a/linphone/gtk-glade/friendlist.c b/linphone/gtk-glade/friendlist.c index 1d76a9d21..863a12087 100644 --- a/linphone/gtk-glade/friendlist.c +++ b/linphone/gtk-glade/friendlist.c @@ -451,7 +451,8 @@ static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list){ gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item); g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_remove_contact,contact_list); - if (ssc && sip_setup_context_get_capabilities(ssc) & SIP_SETUP_CAP_BUDDY_LOOKUP){ + g_message("ssc=%p",ssc); + if (ssc && (sip_setup_context_get_capabilities(ssc) & SIP_SETUP_CAP_BUDDY_LOOKUP)) { menu_item=gtk_image_menu_item_new_with_label(_("Search contact")); image=gtk_image_new_from_stock(GTK_STOCK_FIND,GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),image); diff --git a/linphone/share/C/Makefile.am b/linphone/share/C/Makefile.am index 0d6136465..ecd7c9e56 100644 --- a/linphone/share/C/Makefile.am +++ b/linphone/share/C/Makefile.am @@ -3,6 +3,6 @@ HELPLANG=C include ../Makefile.inc -man_MANS = linphone.1 linphonec.1 sipomatic.1 +man_MANS = linphone.1 linphonec.1 sipomatic.1 linphonecsh.1 EXTRA_DIST+=$(man_MANS)