diff --git a/sflphone-client-gnome/src/imwindow.c b/sflphone-client-gnome/src/imwindow.c index e9bb916c1f3938d08aa050b26482c7f3132e4940..c76b66588d6e519277f151f2b3ce1d6e01bdffd7 100644 --- a/sflphone-client-gnome/src/imwindow.c +++ b/sflphone-client-gnome/src/imwindow.c @@ -146,7 +146,7 @@ im_window_is_active () if (!im_window) return FALSE; else - return gtk_window_is_active (im_window); + return gtk_window_is_active (GTK_WINDOW (im_window)); } gboolean diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp index 6b369c10d5ce6e7320af4ba56ee81ac4ff649423..fa5bc545f43567afafae2ae1f59b2c51494be993 100644 --- a/sflphone-common/src/account.cpp +++ b/sflphone-common/src/account.cpp @@ -39,7 +39,7 @@ Account::Account (const AccountID& accountID, std::string type) : , _enabled (true) , _type (type) , _codecOrder () - , _codecStr ("") + , _codecStr ("0/") , _ringtonePath ("/usr/share/sflphone/ringtones/konga.ul") , _ringtoneEnabled (true) , _displayName ("") @@ -83,11 +83,12 @@ void Account::loadAudioCodecs (void) // if the user never set the codec list, use the default configuration for this account if (_codecStr == "") { - _info ("Account: use the default order"); + _info ("Account: Use default codec order"); Manager::instance ().getCodecDescriptorMap ().setDefaultOrder(); } // else retrieve the one set in the user config file else { + _debug ("Account: Set codec order from configuration file"); std::vector active_list = Manager::instance ().retrieveActiveCodecs(); // This property is now set per account basis // std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs"); diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index 793ddd5a806577bf616424db8dde8eb47fe869c6..10ca4f887bdd40030751edf99d10c116c5b97f69 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -346,9 +346,10 @@ class Account : public Serializable // assignment operator Account& operator= (const Account& rh); + protected: + void loadAudioCodecs (void); - protected: /** * Account ID are assign in constructor and shall not changed */ diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 8bbc44abbce67a2dde7a19e3952ec0d170913136..a930f8658a49303e994fd0f52c57abf041a12c20 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2342,7 +2342,6 @@ void ManagerImpl::initConfigFile (bool load_user_value, std::string alternate) (alternate == "") ? path = _path : path = alternate; std::cout << path << std::endl; - _exist = _config.populateFromFile (path); } _debug ("Manager: configuration file path: %s", path.c_str()); diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp index 65f05626c6149e57b12b80fb63c52b8175b3adeb..61809766d1fdac611f6f45f4a6b1f19ad3bd9c39 100644 --- a/sflphone-common/src/sip/sdp.cpp +++ b/sflphone-common/src/sip/sdp.cpp @@ -663,6 +663,9 @@ void Sdp::set_local_media_capabilities (CodecOrder selectedCodecs) /* We retrieve the codecs selected by the user */ codecs_list = Manager::instance().getCodecDescriptorMap().getCodecsMap(); + if (selectedCodecs.size() == 0) + _warn ("SDP: No selected codec while building local SDP offer"); + for (i=0; igetLocalSDP()->set_ip_address (addrSdp); call->getLocalSDP()->create_initial_offer (account->getActiveCodecs ()); - // Audio Rtp Session must be initialized before creating initial offer in SDP session // since SDES require crypto attribute. try { @@ -1797,10 +1795,12 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) // Create the dialog (UAC) // (Parameters are "strduped" inside this function) + _debug ("UserAgent: Creating dialog for this call"); status = pjsip_dlg_create_uac (pjsip_ua_instance(), &pjFrom, &pjContact, &pjTo, NULL, &dialog); PJ_ASSERT_RETURN (status == PJ_SUCCESS, false); // Create the invite session for this call + _debug ("UserAgent: Creating invite session for this call"); status = pjsip_inv_create_uac (dialog, call->getLocalSDP()->get_local_sdp_session(), 0, &inv); PJ_ASSERT_RETURN (status == PJ_SUCCESS, false); @@ -3208,7 +3208,9 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e) const pj_str_t * description = pjsip_get_status_text (statusCode); if (statusCode) { - DBusManager::instance().getCallManager()->sipCallStateChanged (call->getCallId(), std::string (description->ptr, description->slen), statusCode); + // test wether or not dbus manager is instantiated, if not no need to notify the client + if (Manager::instance().getDbusManager()) + DBusManager::instance().getCallManager()->sipCallStateChanged (call->getCallId(), std::string (description->ptr, description->slen), statusCode); } } diff --git a/sflphone-common/test/Makefile.am b/sflphone-common/test/Makefile.am index c1fb3a2fab62863d8411494aa46bf0bc517a74bc..a4ef53667347f4b4b83ed8972228e4842783ea13 100644 --- a/sflphone-common/test/Makefile.am +++ b/sflphone-common/test/Makefile.am @@ -23,6 +23,8 @@ test_SOURCES = \ numbercleanertest.cpp \ pluginmanagertest.h \ pluginmanagertest.cpp \ + siptest.h \ + siptest.cpp \ rtptest.h \ rtptest.cpp \ sdesnegotiatortest.h \ diff --git a/sflphone-common/test/siptest.cpp b/sflphone-common/test/siptest.cpp index 9d741a5aea18c1e331fe0952d1f1f628b72fb8b5..07767ca0e7274ce47b7006c03589db1c6c82906b 100644 --- a/sflphone-common/test/siptest.cpp +++ b/sflphone-common/test/siptest.cpp @@ -28,19 +28,113 @@ * as that of the covered work. */ +#include #include #include #include +#include +#include + #include "siptest.h" +#include "manager.h" using std::cout; using std::endl; +pthread_t thethread; + + + + + +void *sippThread(void *threadid) +{ + + std::cout << "SIPTest: Starting sipp" << std::endl; + + // Set up the sipp instance in this thread in order to catch return value + // 0: All calls were successful + // 1: At least one call failed + // 97: exit on internal command. Calls may have been processed + // 99: Normal exit without calls processed + // -1: Fatal error + // -2: Fatal error binding a socket + int i = system("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1 -f 0 -trace_msg -trace_stat"); + + CPPUNIT_ASSERT(i==0); + + pthread_exit(NULL); + +} + + void SIPTest::setUp() { + + /* + int rc = pthread_create(&thethread, NULL, sippThread, NULL); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; + } + */ } void SIPTest::tearDown() { + /* + + void *status; + + int rc = pthread_join(thethread, &status); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; + } + else + std::cout << " SIPTest: completed join with thread" << std::endl; + + */ +} + + +void SIPTest::testSimpleIpCall () +{ + + + + std::string testaccount("IP2IP"); + std::string testcallid("callid1234"); + std::string testcallnumber("sip:test@127.0.0.1:5062"); + + CPPUNIT_ASSERT(!Manager::instance().hasCurrentCall()); + + // start a new call sending INVITE message to sipp instance + Manager::instance().outgoingCall(testaccount, testcallid, testcallnumber); + + // must sleep here until receiving 180 and 200 message from peer + sleep(2); + + CPPUNIT_ASSERT(Manager::instance().hasCurrentCall()); + + CPPUNIT_ASSERT(Manager::instance().getCurrentCallId() == testcallid); + + std::map::iterator iterCallDetails; + std::map callDetails = Manager::instance().getCallDetails (testcallid); + + iterCallDetails = callDetails.find("ACCOUNTID"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "")); + iterCallDetails = callDetails.find("PEER_NUMBER"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "")); + iterCallDetails = callDetails.find("PEER_NAME"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "")); + iterCallDetails = callDetails.find("DISPLAY_NAME"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "")); + iterCallDetails = callDetails.find("CALL_STATE"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "CURRENT")); + iterCallDetails = callDetails.find("CALL_TYPE"); + CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "1")); + + Manager::instance().hangupCall(testcallid); + } + diff --git a/sflphone-common/test/siptest.h b/sflphone-common/test/siptest.h index 9198f6c71815e14b7f2397bf7a97a417a857f8b3..7f110210492bf9beb03d92097b44e1afdb348816 100644 --- a/sflphone-common/test/siptest.h +++ b/sflphone-common/test/siptest.h @@ -52,7 +52,8 @@ class SIPTest : public CppUnit::TestCase { /** * Use cppunit library macros to add unit test the factory */ - CPPUNIT_TEST_SUITE( InstantMessagingTest ); + CPPUNIT_TEST_SUITE( SIPTest ); + CPPUNIT_TEST ( testSimpleIpCall ); CPPUNIT_TEST_SUITE_END(); public: @@ -70,6 +71,9 @@ class SIPTest : public CppUnit::TestCase { */ inline void tearDown (); + + void testSimpleIpCall(void); + private: };