diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp index e22cf874d059f8641fa5341b8ea618eea4a1feba..9876b4fd891f51cdf47982c89d0d0403a181cad7 100644 --- a/sflphone-common/src/account.cpp +++ b/sflphone-common/src/account.cpp @@ -23,7 +23,10 @@ #include "manager.h" Account::Account (const AccountID& accountID, std::string type) : - _accountID (accountID), _link (NULL), _enabled (false), _type (type) + _accountID (accountID) + , _link (NULL) + , _enabled (false) + , _type (type) { setRegistrationState (Unregistered); } diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index fbbaedbd089424fb3be140f64bba591554e83dd3..72eee8cda7c126ef5f1d16adc653d2bdc1582257 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -178,12 +178,6 @@ class Account{ */ std::string _alias; - /* - * The account type - * IAX2 or SIP - */ - std::string _type; - /** * Voice over IP Link contains a listener thread and calls */ @@ -196,6 +190,12 @@ class Account{ */ bool _enabled; + /* + * The account type + * IAX2 or SIP + */ + std::string _type; + /* * The registration state of the account */ diff --git a/sflphone-common/src/audio/audiostream.cpp b/sflphone-common/src/audio/audiostream.cpp index 70a7eff154eb8f7a66a064d89f3413b045eabfe1..fe56b85ed59856f0c1faf1c39c1449bb291984a7 100644 --- a/sflphone-common/src/audio/audiostream.cpp +++ b/sflphone-common/src/audio/audiostream.cpp @@ -88,6 +88,8 @@ AudioStream::drainStream(void) { pa_threaded_mainloop_unlock(_mainloop); } + + return true; } bool diff --git a/sflphone-common/src/hooks/urlhook.cpp b/sflphone-common/src/hooks/urlhook.cpp index cdf27b8fa009be54f15229ee7b4e941641fe173f..b50aa1febbf33ecaefc5d681f0d7330ffda035d8 100644 --- a/sflphone-common/src/hooks/urlhook.cpp +++ b/sflphone-common/src/hooks/urlhook.cpp @@ -32,9 +32,7 @@ int UrlHook::addAction (std::string field_value, std::string command) /* Execute the command in the background to not block the application */ command_bg = command + " " + field_value + "&" ; /* Execute a system call */ - RUN_COMMAND (command_bg.c_str()); - - return 0; + return RUN_COMMAND (command_bg.c_str()); } diff --git a/sflphone-common/src/iaxvoiplink.cpp b/sflphone-common/src/iaxvoiplink.cpp index a5b29b3850ae9ef94e26194abcaa0b771a04af2f..8afce85a9acc3e82b2e6215b8e57166ad1ded67b 100644 --- a/sflphone-common/src/iaxvoiplink.cpp +++ b/sflphone-common/src/iaxvoiplink.cpp @@ -920,7 +920,6 @@ void IAXVoIPLink::iaxHandleRegReply (iax_event* event) { - int new_voicemails; std::string account_id; IAXAccount *account; diff --git a/sflphone-common/src/main.cpp b/sflphone-common/src/main.cpp index 5eb4ced27b32e05bef7775f6e650641fe52dbdc9..2ff273978514238287f68fc5f182bddaab85089d 100644 --- a/sflphone-common/src/main.cpp +++ b/sflphone-common/src/main.cpp @@ -86,24 +86,29 @@ main (int argc, char **argv) } } else { // PID file exists. Check the former process still alive or not. If alive, give user a hint. - fgets (cOldPid, 64, fp); - fclose (fp); - - if (kill (atoi (cOldPid), 0) == SUCCESS) { - fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n"); - exit (-1); - } else { - if ( (fp = fopen (homepid,"w")) == NULL) { - fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid); - exit (-1); - } else { - fputs (cPid , fp); - fclose (fp); - } - - } - } - + char *res; + res = fgets (cOldPid, 64, fp); + if (res == NULL) perror ("Error getting string from stream"); + + else + { + fclose (fp); + + if (kill (atoi (cOldPid), 0) == SUCCESS) { + fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n"); + exit (-1); + } else { + if ( (fp = fopen (homepid,"w")) == NULL) { + fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid); + exit (-1); + } else { + fputs (cPid , fp); + fclose (fp); + } + + } + } + } int sessionPort = 0; if (argc == 2) { diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index d7d337d084f2ba68a5ccdb12f5de27d5240562d6..654a173d7fc1ec4ab2a4ea203bdbcfc6b287e5c3 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -286,7 +286,6 @@ ManagerImpl::answerCall (const CallID& id) AccountID currentaccountid = getAccountFromCall (id); Call* currentcall = getAccountLink (currentaccountid)->getCall (getCurrentCallId()); - _debug ("ManagerImpl::answerCall :: current call->getState %i \n",currentcall->getState()); if (currentcall->getState() == 1) isActive = true; @@ -1050,19 +1049,12 @@ bool ManagerImpl::playATone (Tone::TONEID toneId) void ManagerImpl::stopTone (bool stopAudio=true) { int hasToPlayTone; - AudioLayer *audiolayer; hasToPlayTone = getConfigInt (SIGNALISATION, PLAY_TONES); if (!hasToPlayTone) return; - // if (stopAudio) { - // audiolayer = getAudioDriver(); - // if (audiolayer) audiolayer->stopStream(); - // } - - _toneMutex.enterMutex(); if (_telephoneTone != 0) { @@ -1628,10 +1620,14 @@ ManagerImpl::getAudioOutputDeviceList (void) { _debug ("Get audio output device list\n"); AlsaLayer *layer; + std::vector <std::string> devices; layer = dynamic_cast<AlsaLayer*> (getAudioDriver ()); - if (layer) return layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK); + if (layer) + devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK); + + return devices; } /** @@ -1664,12 +1660,15 @@ ManagerImpl::setAudioOutputDevice (const int index) std::vector<std::string> ManagerImpl::getAudioInputDeviceList (void) { - _debug ("Get audio input device list\n"); AlsaLayer *audiolayer; + std::vector <std::string> devices; audiolayer = dynamic_cast<AlsaLayer *> (getAudioDriver()); - if (audiolayer) return audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE); + if (audiolayer) + devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE); + + return devices; } /** @@ -1932,7 +1931,7 @@ ManagerImpl::setPulseAppVolumeControl (void) void ManagerImpl::setAudioManager (const int32_t& api) { - int type, samplerate, framesize, numCardIn, numCardOut; + int type; std::string alsaPlugin; _debug ("Setting audio manager \n"); @@ -1984,7 +1983,10 @@ ManagerImpl::getAudioDeviceIndex (const std::string name) alsalayer = dynamic_cast<AlsaLayer *> (getAudioDriver()); - if (alsalayer) return alsalayer -> soundCardGetIndex (name); + if (alsalayer) + return alsalayer -> soundCardGetIndex (name); + else + return 0; } std::string @@ -2390,7 +2392,7 @@ ManagerImpl::getAccountList() { std::vector< std::string > v; std::vector< std::string > account_order; - int i; + unsigned int i; account_order = loadAccountOrder (); AccountMap::iterator iter; @@ -2476,7 +2478,6 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma std::string accountType; Account *acc; - VoIPLink *link; accountType = (*details.find (CONFIG_ACCOUNT_TYPE)).second; @@ -2681,7 +2682,7 @@ ManagerImpl::loadAccountMap() short nbAccount = 0; TokenList sections = _config.getSections(); std::string accountType; - Account* tmpAccount; + Account *tmpAccount = 0; std::vector <std::string> account_order; TokenList::iterator iter = sections.begin(); @@ -2811,25 +2812,6 @@ ManagerImpl::getAccountIdFromNameAndServer (const std::string& userName, const s return AccountNULL; } -AccountMap ManagerImpl::getSipAccountMap (void) -{ - - AccountMap::iterator iter; - AccountMap sipaccounts; - AccountID id; - Account *account; - - for (iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) { - if (iter->second->getType() == "sip") { - //id = iter->first; - //account = iter->second; - //sipaccounts.insert( std::pair<id, account> ); - } - } - - return sipaccounts; -} - void ManagerImpl::restartPJSIP (void) { SIPVoIPLink *siplink; @@ -3133,7 +3115,6 @@ std::vector< std::string > ManagerImpl::getCallList (void) { std::vector< std::string > v; - int i; CallAccountMap::iterator iter = _callAccountMap.begin (); diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index a7d1ed4fb31d68599624848ac1a7832ea7cc9286..eef8c251f6fbfe973f28a26b67c8dd14551a9f97 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -893,11 +893,6 @@ class ManagerImpl { void registerCurSIPAccounts(VoIPLink *link); - /** - * Returns a map with only the existing SIP accounts - */ - AccountMap getSipAccountMap( void ); - /* * Initialize audiodriver */ diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp index 44a33bb2808435a151aa7902390557a520c26b43..998f91c3b0b4c508180da3133a0b6e7d13ebfe3a 100644 --- a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp +++ b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp @@ -207,6 +207,9 @@ bool AudioRecord::setRecording() recordingEnabled_ = true; // once opend file, start recording } + // WARNING: Unused return value + return true; + } void AudioRecord::stopRecording() @@ -344,6 +347,8 @@ bool AudioRecord::openExistingRawFile() _debug ("AudioRecord::openExistingRawFile() : could not create RAW file!\n"); return false; } + + return true; } @@ -386,6 +391,8 @@ bool AudioRecord::openExistingWavFile() if (fseek (fp, 4 , SEEK_END) != 0) _debug ("AudioRecors::OpenExistingWavFile : 2.Couldn't seek at the en of the file \n"); + return true; + } diff --git a/sflphone-common/src/sdp.cpp b/sflphone-common/src/sdp.cpp index 3b5a0a347761838435e4cfb9da2d77c8300ad3e3..64ef13ad7016794e407171685bbbf8d42d1ff3dc 100644 --- a/sflphone-common/src/sdp.cpp +++ b/sflphone-common/src/sdp.cpp @@ -35,7 +35,14 @@ static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 }; Sdp::Sdp (pj_pool_t *pool) - : _local_media_cap(), _session_media (0), _ip_addr (""), _local_offer (NULL), _negociated_offer (NULL), _negociator (NULL), _pool (NULL), _local_extern_audio_port (0) + : _local_media_cap() + , _session_media (0) + , _negociator (NULL) + , _ip_addr ("") + , _local_offer (NULL) + , _negociated_offer (NULL) + , _pool (NULL) + , _local_extern_audio_port (0) { _pool = pool; } @@ -206,8 +213,8 @@ int Sdp::receiving_initial_offer (pjmedia_sdp_session* remote) pj_status_t Sdp::check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata) { - static const pj_str_t str_application = { "application", 11 }; - static const pj_str_t str_sdp = { "sdp", 3 }; + static const pj_str_t str_application = { (char*) "application", 11 }; + static const pj_str_t str_sdp = { (char*) "sdp", 3 }; pj_status_t status; pjsip_msg * message = NULL; pjmedia_sdp_session * remote_sdp = NULL; @@ -469,7 +476,7 @@ void Sdp::set_local_media_capabilities () { CodecOrder selected_codecs; - int i; + unsigned int i; sdpMedia *audio; CodecsMap codecs_list; CodecsMap::iterator iter; diff --git a/sflphone-common/src/sdp.h b/sflphone-common/src/sdp.h index fcd28db15eabc1aabfc0b0d91292829037572204..be88ff0e20583ba40f4ce967fa03a6d77e766c36 100644 --- a/sflphone-common/src/sdp.h +++ b/sflphone-common/src/sdp.h @@ -220,15 +220,15 @@ class Sdp { // negociation, with the compatible media from each part pjmedia_sdp_session *_negociated_offer; + // The pool to allocate memory + pj_pool_t *_pool; + /** Local audio port */ int _local_extern_audio_port; /** Remote's audio port */ unsigned int _remote_audio_port; - // The pool to allocate memory - pj_pool_t *_pool; - Sdp(const Sdp&); //No Copy Constructor Sdp& operator=(const Sdp&); //No Assignment Operator diff --git a/sflphone-common/src/sipaccount.cpp b/sflphone-common/src/sipaccount.cpp index 8d926c439fb410ea50ac9bb22e2d07b42f92b237..7618e16b331f6bde43ea28f6f57efd225e77a526 100644 --- a/sflphone-common/src/sipaccount.cpp +++ b/sflphone-common/src/sipaccount.cpp @@ -25,10 +25,10 @@ SIPAccount::SIPAccount (const AccountID& accountID) : Account (accountID, "sip") , _cred (NULL) + , _regc() , _bRegister (false) , _contact ("") , _resolveOnce (false) - , _regc() { /* SIPVoIPlink is used as a singleton, because we want to have only one link for all the SIP accounts created */ /* So instead of creating a new instance, we just fetch the static instance, or create one if it is not yet */ diff --git a/sflphone-common/src/sipcall.h b/sflphone-common/src/sipcall.h index fd0c01bea6569e1c2cf3e51d703259acfd090cf4..b9db165779825f21bfffb69201546ca8c4e66ed2 100644 --- a/sflphone-common/src/sipcall.h +++ b/sflphone-common/src/sipcall.h @@ -97,8 +97,6 @@ class SIPCall : public Call private: - Sdp *_local_sdp; - int _cid; int _did; int _tid; @@ -111,7 +109,11 @@ class SIPCall : public Call pjsip_evsub *_xferSub; - pjsip_inv_session *_invSession; + + pjsip_inv_session *_invSession; + + Sdp *_local_sdp; + }; #endif diff --git a/sflphone-common/src/sipvoiplink.cpp b/sflphone-common/src/sipvoiplink.cpp index 0e4a4cb0b64a31057f4b0937001e92ab00c34276..b3e32c2382e9761c42c8889a7bb0b6e498e801bf 100644 --- a/sflphone-common/src/sipvoiplink.cpp +++ b/sflphone-common/src/sipvoiplink.cpp @@ -33,25 +33,25 @@ #define CAN_REINVITE 1 static char * invitationStateMap[] = { -"PJSIP_INV_STATE_NULL", -"PJSIP_INV_STATE_CALLING", -"PJSIP_INV_STATE_INCOMING", -"PJSIP_INV_STATE_EARLY", -"PJSIP_INV_STATE_CONNECTING", -"PJSIP_INV_STATE_CONFIRMED", -"PJSIP_INV_STATE_DISCONNECTED" +(char*) "PJSIP_INV_STATE_NULL", +(char*) "PJSIP_INV_STATE_CALLING", +(char*) "PJSIP_INV_STATE_INCOMING", +(char*) "PJSIP_INV_STATE_EARLY", +(char*) "PJSIP_INV_STATE_CONNECTING", +(char*) "PJSIP_INV_STATE_CONFIRMED", +(char*) "PJSIP_INV_STATE_DISCONNECTED" }; static char * transactionStateMap[] = { -"PJSIP_TSX_STATE_NULL" , -"PJSIP_TSX_STATE_CALLING", -"PJSIP_TSX_STATE_TRYING", -"PJSIP_TSX_STATE_PROCEEDING", -"PJSIP_TSX_STATE_COMPLETED", -"PJSIP_TSX_STATE_CONFIRMED", -"PJSIP_TSX_STATE_TERMINATED", -"PJSIP_TSX_STATE_DESTROYED", -"PJSIP_TSX_STATE_MAX" +(char*) "PJSIP_TSX_STATE_NULL" , +(char*) "PJSIP_TSX_STATE_CALLING", +(char*) "PJSIP_TSX_STATE_TRYING", +(char*) "PJSIP_TSX_STATE_PROCEEDING", +(char*) "PJSIP_TSX_STATE_COMPLETED", +(char*) "PJSIP_TSX_STATE_CONFIRMED", +(char*) "PJSIP_TSX_STATE_TERMINATED", +(char*) "PJSIP_TSX_STATE_DESTROYED", +(char*) "PJSIP_TSX_STATE_MAX" }; struct result @@ -1882,6 +1882,7 @@ bool SIPVoIPLink::pjsip_shutdown (void) pj_shutdown(); /* Done. */ + return true; } int getModId() @@ -1902,7 +1903,7 @@ static void dns_cb(pj_status_t status, void *token, const struct pjsip_server_ad void set_voicemail_info (AccountID account, pjsip_msg_body *body) { - int voicemail, pos_begin, pos_end; + int voicemail = 0, pos_begin, pos_end; std::string voice_str = "Voice-Message: "; std::string delimiter = "/"; std::string msg_body, voicemail_str; @@ -2655,7 +2656,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata) return; } - SIPCall* newCall; + SIPCall* newCall = 0; SIPVoIPLink *link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId)); @@ -2791,7 +2792,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) if (event->body.rx_msg.rdata->msg_info.msg_buf != NULL) { request = event->body.rx_msg.rdata->msg_info.msg_buf; - if (request.find (noresource) != -1) { + if ((int) request.find (noresource) != -1) { _debug ("UserAgent: NORESOURCE for transfer!\n"); link->transferStep2(); pjsip_evsub_terminate (sub, PJ_TRUE); @@ -2800,7 +2801,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) return; } - if (request.find (ringing) != -1) { + if ((int) request.find (ringing) != -1) { _debug ("UserAgent: transfered call RINGING!\n"); link->transferStep2(); pjsip_evsub_terminate (sub, PJ_TRUE); diff --git a/sflphone-common/src/sipvoiplink.h b/sflphone-common/src/sipvoiplink.h index 3a0387c36ef7f044f3a5952601c6b5f6b27b8bd9..8dde01c291ec347c57dc07c3a3fb654e8308ab35 100644 --- a/sflphone-common/src/sipvoiplink.h +++ b/sflphone-common/src/sipvoiplink.h @@ -351,9 +351,6 @@ class SIPVoIPLink : public VoIPLink */ bool pjsip_shutdown(void); - /** Do we use stun? */ - bool _useStun; - pj_status_t stunServerResolve(); /** Create SIP UDP Listener */ @@ -363,12 +360,6 @@ class SIPVoIPLink : public VoIPLink std::string getLocalIP() {return _localExternAddress;} - /** Starting sound */ - AudioRtp* _audiortp; - - /** For registration use only */ - int _regPort; - /* Flag to check if the STUN server is valid or not */ bool validStunServer; @@ -381,6 +372,15 @@ class SIPVoIPLink : public VoIPLink /** Local Extern Port is the port seen by peers for SIP listener */ unsigned int _localExternPort; + /** Starting sound */ + AudioRtp* _audiortp; + + /** For registration use only */ + int _regPort; + + /** Do we use stun? */ + bool _useStun; + /** Threading object */ EventThread* _evThread; ost::Mutex _mutexSIP; diff --git a/sflphone-common/src/voiplink.cpp b/sflphone-common/src/voiplink.cpp index 52a28cd88fdf634a851394b28de3d8736726c2cd..9bf46226d3d6509d7df3c40d786d92c5852bd7e0 100644 --- a/sflphone-common/src/voiplink.cpp +++ b/sflphone-common/src/voiplink.cpp @@ -87,7 +87,6 @@ bool VoIPLink::clearCallMap() Account* VoIPLink::getAccountPtr (void) { - Account* account; AccountID id; id = getAccountID();