diff --git a/linphone/coreapi/friend.c b/linphone/coreapi/friend.c index 50938a61f..a5c146dc9 100644 --- a/linphone/coreapi/friend.c +++ b/linphone/coreapi/friend.c @@ -175,6 +175,35 @@ LinphoneFriend *linphone_friend_new_with_addr(const char *addr){ return fr; } +void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result){ + int err; + osip_from_t *fr=NULL; + osip_from_init(&fr); + err=osip_from_parse(fr,uri); + if (err<0){ + char *tmp=NULL; + if (strchr(uri,'@')!=NULL){ + /*try adding sip:*/ + tmp=ms_strdup_printf("sip:%s",uri); + }else if (lc->default_proxy!=NULL){ + /*try adding domain part from default current proxy*/ + osip_from_t *id=NULL; + osip_from_init(&id); + if (osip_from_parse(id,linphone_core_get_identity(lc))==0){ + if (id->url->port!=NULL && strlen(id->url->port)>0) + tmp=ms_strdup_printf("sip:%s@%s:%s",uri,id->url->host,id->url->port); + else tmp=ms_strdup_printf("sip:%s@%s",uri,id->url->host); + } + osip_from_free(id); + } + if (osip_from_parse(fr,tmp)==0){ + /*looks good */ + ms_message("%s interpreted as %s",uri,tmp); + *result=tmp; + }else *result=NULL; + }else *result=ms_strdup(uri); + osip_from_free(fr); +} int linphone_friend_set_sip_addr(LinphoneFriend *lf, const char *addr){ int err; diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index dc2628938..9115a2aa5 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -1091,6 +1091,7 @@ bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, char **rea if (real_parsed_url!=NULL) *real_parsed_url=osip_to_create(sipaddr); if (real_url!=NULL) *real_url=sipaddr; else ms_free(sipaddr); +#if 0 /*if the prompted uri was auto-suffixed with proxy domain, then automatically set a route so that the request goes through the proxy*/ @@ -1107,6 +1108,9 @@ bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, char **rea ms_message("setting automatically a route to %s",*route); } else *route=ms_strdup(tmproute); +#else + if (tmproute) *route=ms_strdup(tmproute); +#endif return TRUE; } } @@ -1667,6 +1671,20 @@ static MSSndCard *get_card_from_string_id(const char *devid, unsigned int cap){ return sndcard; } +bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *devid){ + MSSndCard *sndcard; + sndcard=ms_snd_card_manager_get_card(ms_snd_card_manager_get(),devid); + if (sndcard!=NULL && (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_CAPTURE)) return TRUE; + return FALSE; +} + +bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *devid){ + MSSndCard *sndcard; + sndcard=ms_snd_card_manager_get_card(ms_snd_card_manager_get(),devid); + if (sndcard!=NULL && (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_PLAYBACK)) return TRUE; + return FALSE; +} + int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid){ lc->sound_conf.ring_sndcard=get_card_from_string_id(devid,MS_SND_CARD_CAP_PLAYBACK); return 0; diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index df71afbaf..03a1b16c4 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -633,6 +633,8 @@ int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr); /* sound functions */ /* returns a null terminated static array of string describing the sound devices */ const char** linphone_core_get_sound_devices(LinphoneCore *lc); +bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device); +bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device); int linphone_core_get_ring_level(LinphoneCore *lc); int linphone_core_get_play_level(LinphoneCore *lc); int linphone_core_get_rec_level(LinphoneCore *lc); @@ -660,6 +662,7 @@ void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const cha LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); +void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr); void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf); diff --git a/linphone/gtk-glade/friendlist.c b/linphone/gtk-glade/friendlist.c index 95f1779d0..e5063ed7d 100644 --- a/linphone/gtk-glade/friendlist.c +++ b/linphone/gtk-glade/friendlist.c @@ -120,6 +120,10 @@ void linphone_gtk_contact_activated(GtkTreeView *treeview, GtkTreeViewColumn *column, gpointer user_data) { + linphone_gtk_call_selected(treeview); +} + +void linphone_gtk_contact_clicked(GtkTreeView *treeview){ linphone_gtk_set_selection_to_uri_bar(treeview); } @@ -356,6 +360,7 @@ void linphone_gtk_contact_cancel(GtkWidget *button){ void linphone_gtk_contact_ok(GtkWidget *button){ GtkWidget *w=gtk_widget_get_toplevel(button); LinphoneFriend *lf=(LinphoneFriend*)g_object_get_data(G_OBJECT(w),"friend_ref"); + char *fixed_uri=NULL; gboolean editing=FALSE,show_presence,allow_presence; const gchar *name,*uri; if (lf==NULL){ @@ -367,7 +372,13 @@ void linphone_gtk_contact_ok(GtkWidget *button){ uri=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address"))); show_presence=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"show_presence"))); allow_presence=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"allow_presence"))); - linphone_friend_set_sip_addr(lf,uri); + linphone_core_interpret_friend_uri(linphone_gtk_get_core(),uri,&fixed_uri); + if (fixed_uri==NULL){ + linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !")); + return ; + } + linphone_friend_set_sip_addr(lf,fixed_uri); + ms_free(fixed_uri); linphone_friend_set_name(lf,name); linphone_friend_send_subscribe(lf,show_presence); linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny); diff --git a/linphone/gtk-glade/linphone.h b/linphone/gtk-glade/linphone.h index a4a3f5f26..45bec507f 100644 --- a/linphone/gtk-glade/linphone.h +++ b/linphone/gtk-glade/linphone.h @@ -42,6 +42,7 @@ GtkWidget *linphone_gtk_create_window(const char *window_name); GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name); LinphoneCore *linphone_gtk_get_core(void); GtkWidget *linphone_gtk_get_main_window(); +void linphone_gtk_display_something(GtkMessageType type,const gchar *message); void linphone_gtk_start_call(GtkWidget *button); void linphone_gtk_show_friends(void); void linphone_gtk_show_contact(LinphoneFriend *lf); diff --git a/linphone/gtk-glade/main.glade b/linphone/gtk-glade/main.glade index d1674745e..b5925dc95 100644 --- a/linphone/gtk-glade/main.glade +++ b/linphone/gtk-glade/main.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -348,6 +348,7 @@ Online users + @@ -396,235 +397,17 @@ Online users 4 True - + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 1 - 0 - - - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 2 - 0 - - - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 3 - 0 - - - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - A + D 0 3 4 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 4 - 0 - - - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - 0 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - 0 - - - 2 - 3 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - B - 0 - - - 3 - 4 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 7 - 0 - - - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 8 - 0 - - - 1 - 2 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 9 - 0 - - - 2 - 3 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - C - 0 - - - 3 - 4 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - * - 0 - - - 3 - 4 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - 0 - - - 1 - 2 3 4 @@ -650,19 +433,237 @@ Online users - + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - D + 0 + 0 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + * + 0 + + + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + C 0 3 4 - 3 - 4 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 9 + 0 + + + 2 + 3 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8 + 0 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 7 + 0 + + + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + B + 0 + + + 3 + 4 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 6 + 0 + + + 2 + 3 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 4 + 0 + + + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + A + 0 + + + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 + 0 + + + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 0 + + + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + 0 + + diff --git a/linphone/gtk-glade/propertybox.c b/linphone/gtk-glade/propertybox.c index 3776aada1..0461edba3 100644 --- a/linphone/gtk-glade/propertybox.c +++ b/linphone/gtk-glade/propertybox.c @@ -19,7 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" -static void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, const char *selected){ +typedef enum { + CAP_IGNORE, + CAP_PLAYBACK, + CAP_CAPTURE +}DeviceCap; + +static void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, const char *selected, DeviceCap cap){ const char **p=devices; int i=0,active=0; /* glade creates a combo box without list model and text renderer, @@ -27,8 +33,12 @@ static void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, This dummy text needs to be removed first*/ gtk_combo_box_remove_text(GTK_COMBO_BOX(combo),0); for(;*p!=NULL;++p,++i){ - gtk_combo_box_append_text(GTK_COMBO_BOX(combo),*p); - if (strcmp(selected,*p)==0) active=i; + if ( cap==CAP_IGNORE + || (cap==CAP_CAPTURE && linphone_core_sound_device_can_capture(linphone_gtk_get_core(),*p)) + || (cap==CAP_PLAYBACK && linphone_core_sound_device_can_playback(linphone_gtk_get_core(),*p)) ){ + gtk_combo_box_append_text(GTK_COMBO_BOX(combo),*p); + if (strcmp(selected,*p)==0) active=i; + } } gtk_combo_box_set_active(GTK_COMBO_BOX(combo),active); } @@ -641,13 +651,13 @@ void linphone_gtk_show_parameters(void){ linphone_core_get_use_info_for_dtmf(lc)); /* MUTIMEDIA CONFIG */ linphone_gtk_fill_combo_box(linphone_gtk_get_widget(pb,"playback_device"), sound_devices, - linphone_core_get_playback_device(lc)); + linphone_core_get_playback_device(lc),CAP_PLAYBACK); linphone_gtk_fill_combo_box(linphone_gtk_get_widget(pb,"ring_device"), sound_devices, - linphone_core_get_ringer_device(lc)); + linphone_core_get_ringer_device(lc),CAP_PLAYBACK); linphone_gtk_fill_combo_box(linphone_gtk_get_widget(pb,"capture_device"), sound_devices, - linphone_core_get_capture_device(lc)); + linphone_core_get_capture_device(lc), CAP_CAPTURE); linphone_gtk_fill_combo_box(linphone_gtk_get_widget(pb,"webcams"),linphone_core_get_video_devices(lc), - linphone_core_get_video_device(lc)); + linphone_core_get_video_device(lc),CAP_IGNORE); linphone_gtk_fill_video_sizes(linphone_gtk_get_widget(pb,"video_size")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"echo_cancelation")), linphone_core_echo_cancelation_enabled(lc)); diff --git a/linphone/mediastreamer2/src/alsa.c b/linphone/mediastreamer2/src/alsa.c index 85c0fc00e..3797c1adc 100644 --- a/linphone/mediastreamer2/src/alsa.c +++ b/linphone/mediastreamer2/src/alsa.c @@ -629,6 +629,7 @@ static MSSndCard * alsa_card_new(int id) char *name=NULL; AlsaData *ad; int err; + snd_pcm_t *pcm_handle; if (id!=-1){ err=snd_card_get_name(id,&name); if (err<0) { @@ -652,6 +653,20 @@ static MSSndCard * alsa_card_new(int id) ad->pcmdev=ms_strdup_printf("default:%i",id); ad->mixdev=ms_strdup_printf("default:%i",id); } + /*check card capabilities: */ + obj->capabilities=0; + if (snd_pcm_open(&pcm_handle,ad->pcmdev,SND_PCM_STREAM_CAPTURE,SND_PCM_NONBLOCK)==0) { + obj->capabilities|=MS_SND_CARD_CAP_CAPTURE; + snd_pcm_close(pcm_handle); + } + if (snd_pcm_open(&pcm_handle,ad->pcmdev,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)==0) { + obj->capabilities|=MS_SND_CARD_CAP_PLAYBACK; + snd_pcm_close(pcm_handle); + } + if (obj->capabilities==0){ + ms_warning("Strange, sound card %s does not seems to be capable of anything.",obj->name); + obj->capabilities=MS_SND_CARD_CAP_CAPTURE|MS_SND_CARD_CAP_PLAYBACK; + } free(name); /*ms_message("alsa device %s found",obj->name);*/ return obj;