diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index cebc3835cb1d63302dd4701f5bcebae2a09fef5f..772ed014d165e8a1cefd345e52e15df4d45c8c30 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -1101,12 +1101,12 @@ void sflphone_fill_codec_list () { void sflphone_fill_codec_list_per_account (account_t **account) { - gchar **order; + gchar **order; gchar** details; gchar** pl; - gchar *accountID; - GQueue *codeclist; - gboolean active = FALSE; + gchar *accountID; + GQueue *codeclist; + gboolean active = FALSE; order = (gchar**) dbus_get_active_codec_list ((*account)->accountID); codeclist = (*account)->codecs; @@ -1118,7 +1118,7 @@ void sflphone_fill_codec_list_per_account (account_t **account) { { codec_t * cpy; // Each account will have a copy of the system-wide capabilities - codec_create_new_from_caps (codec_list_get_by_payload ((gconstpointer) atoi (*order), NULL), &cpy); + codec_create_new_from_caps (codec_list_get_by_payload ((gconstpointer) (size_t)atoi (*order), NULL), &cpy); if (cpy) { cpy->is_active = TRUE; codec_list_add (cpy, &codeclist); @@ -1136,7 +1136,7 @@ void sflphone_fill_codec_list_per_account (account_t **account) { codec_t * current_cap = capabilities_get_nth (i); // Check if this codec has already been enabled for this account - if (codec_list_get_by_payload ( (gconstpointer) current_cap->_payload, codeclist) == NULL) { + if (codec_list_get_by_payload ( (gconstpointer) (size_t)(current_cap->_payload), codeclist) == NULL) { // codec_t *cpy; // codec_create_new_from_caps (current_cap, &cpy); current_cap->is_active = active; diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 63f9d9d141326298fc8eef3d5c96207b829a40b3..6dcaf3bad47f8a0d6871446f241921010c37208f 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -116,12 +116,16 @@ void change_protocol_cb (account_t *currentAccount UNUSED) { gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox)); - if (g_strcasecmp (protocol, "IAX") == 0) { - gtk_widget_hide (security_tab); - gtk_widget_hide (advanced_tab); - } else { - gtk_widget_show (security_tab); - gtk_widget_show (advanced_tab); + // Only if tabs are not NULL + if(security_tab && advanced_tab) { + + if (g_strcasecmp (protocol, "IAX") == 0) { + gtk_widget_hide (GTK_WIDGET(security_tab)); + gtk_widget_hide (GTK_WIDGET(advanced_tab)); + } else { + gtk_widget_show (GTK_WIDGET(security_tab)); + gtk_widget_show (GTK_WIDGET(advanced_tab)); + } } } @@ -548,6 +552,7 @@ static void key_exchange_changed_cb(GtkWidget *widget, gpointer data) static void use_sip_tls_cb(GtkWidget *widget, gpointer data) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { DEBUG("Using sips"); gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE); @@ -616,7 +621,6 @@ static local_interface_changed_cb(GtkWidget * widget, gpointer data UNUSED) { static set_published_addr_manually_cb(GtkWidget * widget, gpointer data UNUSED) { - DEBUG("set_published_addr_manually_cb"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { DEBUG("Showing manual options"); @@ -645,7 +649,7 @@ static use_stun_cb(GtkWidget *widget, gpointer data UNUSED) gtk_widget_show (stunServerEntry); gtk_widget_set_sensitive (sameAsLocalRadioButton, FALSE); gtk_widget_set_sensitive (publishedAddrRadioButton, FALSE); - DEBUG("Problem occurs here"); + gtk_widget_hide (publishedAddressLabel); gtk_widget_hide (publishedPortLabel); gtk_widget_hide (publishedAddressEntry); @@ -658,7 +662,7 @@ static use_stun_cb(GtkWidget *widget, gpointer data UNUSED) gtk_widget_set_sensitive (sameAsLocalRadioButton, TRUE); gtk_widget_set_sensitive (publishedAddrRadioButton, TRUE); - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton))) { gtk_widget_show (publishedAddressLabel); gtk_widget_show (publishedPortLabel); gtk_widget_show (publishedAddressEntry); @@ -678,6 +682,7 @@ static use_stun_cb(GtkWidget *widget, gpointer data UNUSED) static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { DEBUG("Same as local"); gchar * local_interface; @@ -692,6 +697,7 @@ static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED) gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL)); } + } @@ -1082,7 +1088,9 @@ GtkWidget* create_published_address (account_t **a) { if (g_strcasecmp (published_sameas_local, "true") == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), FALSE); } else { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), TRUE); } @@ -1115,6 +1123,8 @@ GtkWidget* create_published_address (account_t **a) { g_signal_connect(sameAsLocalRadioButton, "toggled", G_CALLBACK(same_as_local_cb), sameAsLocalRadioButton); g_signal_connect(publishedAddrRadioButton, "toggled", G_CALLBACK(set_published_addr_manually_cb), publishedAddrRadioButton); + set_published_addr_manually_cb(publishedAddrRadioButton, NULL); + return frame; } @@ -1137,6 +1147,7 @@ GtkWidget* create_advanced_tab (account_t **a) { gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); gtk_widget_show_all (ret); + return ret; } @@ -1231,9 +1242,10 @@ void show_account_window (account_t * a) { /* General Settings */ tab = create_basic_tab(¤tAccount); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Basic"))); gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); - g_signal_emit_by_name (protocolComboBox, "changed", NULL); + g_signal_emit_by_name ((gpointer)protocolComboBox, "changed", NULL); } @@ -1415,7 +1427,7 @@ void show_account_window (account_t * a) { codec_list_update_to_daemon (currentAccount); } else { - g_print ("IP to IP call\n"); + DEBUG("IP to IP call\n"); // Direct IP calls config // dbus_set_ip2ip_details (directIpCallsProperties); } diff --git a/sflphone-client-gnome/src/contacts/addressbook.c b/sflphone-client-gnome/src/contacts/addressbook.c index d9b987c6340af544880f01ef9e74ded840bfd2b4..dfa4df26b42c0cb271846b9c07b1400df58b7352 100644 --- a/sflphone-client-gnome/src/contacts/addressbook.c +++ b/sflphone-client-gnome/src/contacts/addressbook.c @@ -32,7 +32,7 @@ void addressbook_search(GtkEntry* entry) { - gchar* query = gtk_entry_get_text(GTK_ENTRY (entry)); + const gchar* query = gtk_entry_get_text(GTK_ENTRY (entry)); if (strlen(query) >= 3) { AddressBook_Config *addressbook_config; diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 48f047c0929ac7515dd142a25e9f6ad61e95026d..f764878d68107399a95bca3333af8270e5c5254d 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -2605,7 +2605,7 @@ void dbus_enable_status_icon (const gchar *value) { gchar* dbus_is_status_icon_enabled (void) { GError *error = NULL; - gchar* value = TRUE; + gchar *value = NULL; org_sflphone_SFLphone_ConfigurationManager_is_status_icon_enabled (configurationManagerProxy, &value, &error); diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index 6fe9cc025c0ea7e4bfd1e604762bf5982a26e5cb..597076303dabc17b65fd6bfccd5f736f9ac710f1 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -105,15 +105,10 @@ main_window_ask_quit () response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - if (response == GTK_RESPONSE_YES) - { - return TRUE; - } - else if (response == GTK_RESPONSE_NO) - { - return FALSE; - } - return TRUE; + + return (response == GTK_RESPONSE_NO)? FALSE : TRUE ; + + } static gboolean diff --git a/sflphone-client-gnome/src/statusicon.c b/sflphone-client-gnome/src/statusicon.c index 7f74f6f066ed8c9d77a52b948658c1d44dae01ae..0808f1a2be5b40815a0d03fcf9593dd231560621 100644 --- a/sflphone-client-gnome/src/statusicon.c +++ b/sflphone-client-gnome/src/statusicon.c @@ -182,13 +182,17 @@ statusicon_set_tooltip() int count; gchar *tip; - // Add a tooltip to the system tray icon - count = account_list_get_registered_accounts(); - tip = g_markup_printf_escaped("%s - %s", _("SFLphone"), - g_markup_printf_escaped( - n_("%i active account", "%i active accounts", count), count)); - gtk_status_icon_set_tooltip(status, tip); - g_free(tip); + if(status) { + + // Add a tooltip to the system tray icon + count = account_list_get_registered_accounts(); + tip = g_markup_printf_escaped("%s - %s", _("SFLphone"), + g_markup_printf_escaped(n_("%i active account", "%i active accounts", count), count)); + gtk_status_icon_set_tooltip(status, tip); + g_free(tip); + + } + } void diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 26b35661b5ae22367fe6d355df1360cbd3d79cf4..a866c3c1a969295836c2188b4082fd01d378efe1 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -362,11 +362,10 @@ help_contents_cb(GtkAction *action) GError *error = NULL; gnome_help_display("sflphone.xml", NULL, &error); - if (error != NULL) - { + if (error != NULL) { g_warning("%s", error->message); g_error_free(error); - } + } } static void diff --git a/sflphone-common/libs/pjproject/pjlib-util/include/pjlib-util/srv_resolver.h b/sflphone-common/libs/pjproject/pjlib-util/include/pjlib-util/srv_resolver.h index 216e91b9e5d525d9807b1d26cd4896b639fba186..d1a292f1f61aca71fc200d9d3c4feedba19685b1 100644 --- a/sflphone-common/libs/pjproject/pjlib-util/include/pjlib-util/srv_resolver.h +++ b/sflphone-common/libs/pjproject/pjlib-util/include/pjlib-util/srv_resolver.h @@ -104,7 +104,19 @@ typedef enum pj_dns_srv_option * this option is not specified, the SRV resolver will query * the DNS A record for the target instead. */ - PJ_DNS_SRV_RESOLVE_AAAA = 4 + PJ_DNS_SRV_RESOLVE_AAAA = 4, + + /** + * Specify if the resolver should fallback to getaddrinfo + * under IPV4 mode if DNS A fails after DNS SRV. + */ + PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV4 = 8, + + /** + * Specify if the resolver should fallback to getaddrinfo + * under IPV6 mode if DNS A fails after DNS SRV. + */ + PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV6 = 16, } pj_dns_srv_option; diff --git a/sflphone-common/libs/pjproject/pjlib-util/src/pjlib-util/srv_resolver.c b/sflphone-common/libs/pjproject/pjlib-util/src/pjlib-util/srv_resolver.c index 83963495574d53a1b9cfdaa596d02629eda89e1d..06abdd7a70d8c6d1fcc7112114d3309eac0a1040 100644 --- a/sflphone-common/libs/pjproject/pjlib-util/src/pjlib-util/srv_resolver.c +++ b/sflphone-common/libs/pjproject/pjlib-util/src/pjlib-util/srv_resolver.c @@ -19,6 +19,7 @@ */ #include <pjlib-util/srv_resolver.h> #include <pjlib-util/errno.h> +#include <pj/addr_resolv.h> #include <pj/array.h> #include <pj/assert.h> #include <pj/log.h> @@ -583,13 +584,53 @@ static void dns_callback(void *user_data, } else if (status != PJ_SUCCESS) { char errmsg[PJ_ERR_MSG_SIZE]; - /* Update last error */ - query_job->last_error = status; - - /* Log error */ - pj_strerror(status, errmsg, sizeof(errmsg)); - PJ_LOG(4,(query_job->objname, "DNS A record resolution failed: %s", - errmsg)); + if ((query_job->option & + (PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV4 | PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV6))) + { + pj_strerror(status, errmsg, sizeof(errmsg)); + PJ_LOG(4,(query_job->objname, + "DNS A record resolution failed: %s," + " trying getaddrinfo()", + errmsg)); + + pj_addrinfo ai; + unsigned count; + int af; + + if ((query_job->option & PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV6)) { + af = pj_AF_INET6(); + } else { + af = pj_AF_INET(); + } + + count = 1; + status = pj_getaddrinfo(af, &query_job->domain_part, &count, &ai); + if (status != PJ_SUCCESS) { + query_job->last_error = status; + pj_strerror(status, errmsg, sizeof(errmsg)); + PJ_LOG(4,(query_job->objname, "DNS resolution failed with getaddrinfo(): %s", + errmsg)); + } else { + + if (srv->addr_cnt < ADDR_MAX_COUNT) { + srv->addr[srv->addr_cnt++].s_addr = ai.ai_addr.ipv4.sin_addr.s_addr; + } + + PJ_LOG(5,(query_job->objname, + "DNS getaddrinfo() for %.*s: %s", + (int)srv->target_name.slen, + srv->target_name.ptr, + pj_inet_ntoa(srv->addr[srv->addr_cnt]))); + } + } else { + /* Update last error */ + query_job->last_error = status; + + /* Log error */ + pj_strerror(status, errmsg, sizeof(errmsg)); + PJ_LOG(4,(query_job->objname, "DNS A record resolution failed: %s", + errmsg)); + } } ++query_job->host_resolved; diff --git a/sflphone-common/libs/pjproject/pjsip/src/pjsip/sip_resolve.c b/sflphone-common/libs/pjproject/pjsip/src/pjsip/sip_resolve.c index 746506d606c993d7f3f055cd8101747f9cfcf174..251bbb9e8b3fa96e03eefc0ed7e89fb82a07e9d9 100644 --- a/sflphone-common/libs/pjproject/pjsip/src/pjsip/sip_resolve.c +++ b/sflphone-common/libs/pjproject/pjsip/src/pjsip/sip_resolve.c @@ -369,14 +369,21 @@ PJ_DEF(void) pjsip_resolve( pjsip_resolver_t *resolver, if (query->query_type == PJ_DNS_TYPE_SRV) { - status = pj_dns_srv_resolve(&query->naptr[0].name, - &query->naptr[0].res_type, - query->req.def_port, pool, resolver->res, - PJ_TRUE, query, &srv_resolver_cb, NULL); + unsigned option = PJ_TRUE; + if (type & PJSIP_TRANSPORT_IPV6) { + option |= PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV6; + } else { + option |= PJ_DNS_SRV_FALLBACK_GETADDRINFO_IPV4; + } + + status = pj_dns_srv_resolve(&query->naptr[0].name, + &query->naptr[0].res_type, + query->req.def_port, pool, resolver->res, + option, query, &srv_resolver_cb, NULL); } else if (query->query_type == PJ_DNS_TYPE_A) { - status = pj_dns_resolver_start_query(resolver->res, + status = pj_dns_resolver_start_query(resolver->res, &query->naptr[0].name, PJ_DNS_TYPE_A, 0, &dns_a_callback, diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index a7cca643c030feb8a0e79895c9990d1373fe3d2e..07f7d70481deade5f63c15f25c9aed56efd4d918 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -560,11 +560,8 @@ int SIPVoIPLink::sendRegister (AccountID id) // Creates URI std::string fromUri; - std::string contactUri; - std::string srvUri; - std::string address; fromUri = account->getFromUri(); @@ -1772,7 +1769,7 @@ bool get_dns_server_addresses (std::vector<std::string> *servers) // Read configuration files if (res_init () != 0) { - _debug ("Resolver initialization failed"); + _debug ("UserAgent: Resolver initialization failed"); return false; } @@ -1797,44 +1794,43 @@ pj_status_t SIPVoIPLink::enable_dns_srv_resolver (pjsip_endpoint *endpt, pj_dns_ std::vector <std::string> dns_servers; int scount, i; + _debug("UserAgent: Enable DNS SRV resolver"); + // Create the DNS resolver instance status = pjsip_endpt_create_resolver (endpt, &resv); - if (status != PJ_SUCCESS) { - _debug ("Error creating the DNS resolver instance"); + _error ("UserAgent: Error: Creating the DNS resolver instance"); return status; } if (!get_dns_server_addresses (&dns_servers)) { - _debug ("Error while fetching DNS information"); + _error ("UserAgent: Error: while fetching DNS information"); return -1; } // Build the nameservers list needed by pjsip if ( (scount = dns_servers.size ()) <= 0) { - _debug ("No server detected while fetching DNS information, stop dns resolution"); + _warn ("UserAgent: No server detected while fetching DNS information, stop dns resolution"); return 0; } pj_str_t nameservers[scount]; - for (i = 0; i<scount; i++) { - nameservers[i] = pj_str ( (char*) dns_servers[i].c_str()); + _debug("UserAgent: Server: %s", (char *)dns_servers[i].c_str()); + nameservers[i] = pj_str ( (char *) dns_servers[i].c_str()); } // Update the name servers for the DNS resolver status = pj_dns_resolver_set_ns (resv, scount, nameservers, NULL); - if (status != PJ_SUCCESS) { - _debug ("Error updating the name servers for the DNS resolver"); + _debug ("UserAgent: Error updating the name servers for the DNS resolver"); return status; } // Set the DNS resolver instance of the SIP resolver engine status = pjsip_endpt_set_resolver (endpt, resv); - if (status != PJ_SUCCESS) { - _debug ("Error setting the DNS resolver instance of the SIP resolver engine"); + _debug ("UserAgent: Error setting the DNS resolver instance of the SIP resolver engine"); return status; } diff --git a/tools/pysflphone/pysflphone_testdbus.py b/tools/pysflphone/pysflphone_testdbus.py index d05da47a9999167af290ac3f4a65c00158da612c..dc17f2bbc9e615a674cedc7584f1e639ca3ed2fe 100644 --- a/tools/pysflphone/pysflphone_testdbus.py +++ b/tools/pysflphone/pysflphone_testdbus.py @@ -135,10 +135,13 @@ class SflPhoneTests(): # Start Glib mainloop self.sflphone.start() + + # SCENARIO 1 Test 4 def test_ip2ip_recv_peer_hungup(self): """Wait for calls, answer, peer hangup""" + # Add callback for this test self.sflphone.onIncomingCall_cb = acceptOnIncomingCall diff --git a/tools/pysflphone/sflphonectrlsimple.py b/tools/pysflphone/sflphonectrlsimple.py index 8de24706aafc65065d397722d9b54dfd570c6075..cba2cf72da9907ce39fefe5a5c4fa6662efd9a11 100755 --- a/tools/pysflphone/sflphonectrlsimple.py +++ b/tools/pysflphone/sflphonectrlsimple.py @@ -71,9 +71,13 @@ class SflPhoneCtrlSimple(Thread): self.loop = MainLoop() + self.isStop = False + self.test = test self.onIncomingCall_cb = None self.event = Event() + + gobject.threads_init() @@ -83,6 +87,12 @@ class SflPhoneCtrlSimple(Thread): self.loop.quit() + def stopThread(self): + print "Stop PySFLphone" + self.isStop = True + + + def register(self): if self.registered: return @@ -614,9 +624,11 @@ class SflPhoneCtrlSimple(Thread): def run(self): """Processing method for this thread""" - gobject.threads_init() - # self.loop.run() + context = self.loop.get_context() - while 1: + while True: context.iteration(True) + + if self.isStop: + return