diff --git a/src/call.cpp b/src/call.cpp index 49914e0ce4b338d021cf6efc4ef767b26a1da9a6..c278a67745eb28867eae00d7d8683e69d4c9786a 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -71,38 +71,26 @@ Call::getVoIPLink (void) return _voIPLink; } -string -Call::getStatus (void) -{ - return _status; -} - -void -Call::setStatus (const string& status) -{ - _status = status; -} - -string +std::string Call::getCallerIdName (void) { return _callerIdName; } void -Call::setCallerIdName (const string& callerId_name) +Call::setCallerIdName (const std::string& callerId_name) { _callerIdName = callerId_name; } -string +std::string Call::getCallerIdNumber (void) { return _callerIdNumber; } void -Call::setCallerIdNumber (const string& callerId_number) +Call::setCallerIdNumber (const std::string& callerId_number) { _callerIdNumber = callerId_number; } @@ -219,7 +207,7 @@ Call::isIncomingType (void) } int -Call::outgoingCall(const string& to) +Call::outgoingCall(const std::string& to) { return _voIPLink->outgoingInvite(_id, to); } @@ -228,7 +216,6 @@ int Call::hangup (void) { int i = _voIPLink->hangup(_id); - _voIPLink->deleteSipCall(_id); return i; } @@ -236,7 +223,6 @@ int Call::cancel (void) { int i = _voIPLink->cancel(_id); - _voIPLink->deleteSipCall(_id); return i; } @@ -262,7 +248,7 @@ Call::offHold (void) } int -Call::transfer (const string& to) +Call::transfer (const std::string& to) { int i = _voIPLink->transfer(_id, to); return i; @@ -272,7 +258,6 @@ int Call::refuse (void) { int i = _voIPLink->refuse(_id); - _voIPLink->deleteSipCall(_id); return i; } diff --git a/src/call.h b/src/call.h index df13ddcb1de408733917733ae073a483c7060f90..5b36db83fa1de690006724fd8b8ae3ff05587d03 100644 --- a/src/call.h +++ b/src/call.h @@ -66,10 +66,6 @@ public: VoIPLink* getVoIPLink(void); void setVoIPLink (VoIPLink* voIPLink); - // Accessor and modifior of status - std::string getStatus (void); - void setStatus (const std::string& status); - // Handle id name and id number std::string getCallerIdName (void); void setCallerIdName (const std::string& callerId_name); @@ -117,7 +113,6 @@ private: enum CallType _type; std::string _callerIdName; std::string _callerIdNumber; - std::string _status; }; #endif // __CALL_H__ diff --git a/src/gui/qt/qtGUImainwindow.cpp b/src/gui/qt/qtGUImainwindow.cpp index d3bc944a8c87721e4f22f8591fbefbd9a3c54aad..5775e1b17c13cec2703154f359ca282f4f3427ab 100644 --- a/src/gui/qt/qtGUImainwindow.cpp +++ b/src/gui/qt/qtGUImainwindow.cpp @@ -877,7 +877,7 @@ QtGUIMainWindow::peerAnsweredCall (short id) setChooseLine(false); } -int +void QtGUIMainWindow::peerRingingCall (short id) { getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus())); @@ -885,7 +885,7 @@ QtGUIMainWindow::peerRingingCall (short id) } -int +void QtGUIMainWindow::peerHungupCall (short id) { int line = id2line(id); diff --git a/src/gui/qt/qtGUImainwindow.h b/src/gui/qt/qtGUImainwindow.h index 25bfe0c0a28ddcebc74fb12bdf35511f2601d2e2..f6420e824c7884f10162094a82aa0ec02177f884 100644 --- a/src/gui/qt/qtGUImainwindow.h +++ b/src/gui/qt/qtGUImainwindow.h @@ -86,8 +86,8 @@ public: // Reimplementation of virtual functions virtual int incomingCall (short id); virtual void peerAnsweredCall (short id); - virtual int peerRingingCall (short id); - virtual int peerHungupCall (short id); + virtual void peerRingingCall (short id); + virtual void peerHungupCall (short id); virtual void displayTextMessage (short id, const std::string& message); virtual void displayErrorText (short id, const std::string& message); virtual void displayError (const std::string& error); diff --git a/src/gui/server/request.cpp b/src/gui/server/request.cpp index b4fe6c7166441818b052d5db5a95c556c6191e09..22a2a2d018a842342aef7f5ce7e208c813afecd8 100644 --- a/src/gui/server/request.cpp +++ b/src/gui/server/request.cpp @@ -204,6 +204,7 @@ RequestVersion::execute() ResponseMessage RequestQuit::execute() { + GUIServer::instance().stopTone(); GUIServer::instance().quit(); return message("200", "Quitting"); } @@ -211,6 +212,7 @@ RequestQuit::execute() ResponseMessage RequestStop::execute() { + GUIServer::instance().stopTone(); GUIServer::instance().stop(); return message("200", "Stopping server"); } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index fb66afe80df9350f9458e378d76a338de8a34902..5336127b52d4ce799c4d7d0e40a1a9e5569eb88d 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -21,12 +21,8 @@ #include <errno.h> #include <time.h> -# include <sys/types.h> // mkdir(2) -# include <sys/stat.h> // mkdir(2) - -//#include <sys/socket.h> // inet_ntoa() -//#include <netinet/in.h> -//#include <arpa/inet.h> +#include <sys/types.h> // mkdir(2) +#include <sys/stat.h> // mkdir(2) #include <cc++/thread.h> #include <cc++/file.h> @@ -59,8 +55,8 @@ #define fill_config_int(name, value) \ (_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_int))) -using namespace std; -using namespace ost; +//using namespace std; +//using namespace ost; ManagerImpl::ManagerImpl (void) { @@ -309,13 +305,12 @@ ManagerImpl::deleteCall (short id) * Main thread */ int -ManagerImpl::outgoingCall (const string& to) +ManagerImpl::outgoingCall (const std::string& to) { short id = generateNewCallId(); Call *call = pushBackNewCall(id, Outgoing); _debug("Outgoing Call with identifiant %d\n", id); - call->setStatus(string(TRYING_STATUS)); call->setState(Call::Progressing); call->setCallerIdNumber(to); if (call->outgoingCall(to) == 0) { @@ -339,7 +334,6 @@ ManagerImpl::hangupCall (short id) if (call == NULL) { return -1; } - call->setStatus(string(HANGUP_STATUS)); call->setState(Call::Hungup); int result = call->hangup(); @@ -364,7 +358,6 @@ ManagerImpl::cancelCall (short id) call = getCall(id); if (call == NULL) return -1; - call->setStatus(string(HANGUP_STATUS)); call->setState(Call::Hungup); _mutex.enterMutex(); _nCalls -= 1; @@ -390,7 +383,6 @@ ManagerImpl::answerCall (short id) if (call == NULL) return -1; - call->setStatus(string(CONNECTED_STATUS)); call->setState(Call::Answered); if (call->isIncomingType()) { @@ -412,7 +404,6 @@ ManagerImpl::onHoldCall (short id) call = getCall(id); if (call == NULL) return -1; - call->setStatus(string(ONHOLD_STATUS)); call->setState(Call::OnHold); return call->onHold(); } @@ -428,7 +419,6 @@ ManagerImpl::offHoldCall (short id) call = getCall(id); if (call == NULL) return -1; - call->setStatus(string(CONNECTED_STATUS)); call->setState(Call::OffHold); setCurrentCallId(id); int returnValue = call->offHold(); @@ -443,13 +433,12 @@ ManagerImpl::offHoldCall (short id) * Every Call */ int -ManagerImpl::transferCall (short id, const string& to) +ManagerImpl::transferCall (short id, const std::string& to) { Call* call; call = getCall(id); if (call == NULL) return -1; - call->setStatus(string(TRANSFER_STATUS)); call->setState(Call::Transfered); setCurrentCallId(0); return call->transfer(to); @@ -485,7 +474,6 @@ ManagerImpl::muteOn (short id) call = getCall(id); if (call == NULL) return; - call->setStatus(string(MUTE_ON_STATUS)); call->setState(Call::MuteOn); } @@ -500,7 +488,6 @@ ManagerImpl::muteOff (short id) call = getCall(id); if (call == NULL) return; - call->setStatus(string(CONNECTED_STATUS)); call->setState(Call::MuteOff); } @@ -525,7 +512,6 @@ ManagerImpl::refuseCall (short id) if ( call->getState() != Call::Progressing ) return -1; - call->setStatus(string(HANGUP_STATUS)); call->setState(Call::Refused); _mutex.enterMutex(); @@ -588,7 +574,7 @@ ManagerImpl::unregisterVoIPLink (void) * ??? action */ int -ManagerImpl::sendTextMessage (short , const string& ) +ManagerImpl::sendTextMessage (short , const std::string& ) { return 1; } @@ -725,7 +711,6 @@ ManagerImpl::incomingCall (short id) return -1; call->setType(Incoming); - call->setStatus(string(RINGING_STATUS)); call->setState(Call::Progressing); incWaitingCall(); @@ -753,7 +738,6 @@ ManagerImpl::peerAnsweredCall (short id) stopTone(); Call* call = getCall(id); - call->setStatus(string(CONNECTED_STATUS)); call->setState(Call::Answered); // switch current call @@ -769,7 +753,6 @@ int ManagerImpl::peerRingingCall (short id) { Call* call = getCall(id); - call->setStatus(string(RINGING_STATUS)); call->setState(Call::Ringing); // ring @@ -793,7 +776,6 @@ ManagerImpl::peerHungupCall (short id) decWaitingCall(); } - call->setStatus(string(HANGUP_STATUS)); call->setState(Call::Hungup); if (_gui) _gui->peerHungupCall(id); @@ -812,7 +794,7 @@ ManagerImpl::peerHungupCall (short id) * for outgoing call, send by SipEvent */ void -ManagerImpl::displayTextMessage (short id, const string& message) +ManagerImpl::displayTextMessage (short id, const std::string& message) { if(_gui) { _gui->displayTextMessage(id, message); @@ -824,7 +806,7 @@ ManagerImpl::displayTextMessage (short id, const string& message) * for outgoing call, send by SipEvent */ void -ManagerImpl::displayErrorText (short id, const string& message) +ManagerImpl::displayErrorText (short id, const std::string& message) { if(_gui) { _gui->displayErrorText(id, message); @@ -836,7 +818,7 @@ ManagerImpl::displayErrorText (short id, const string& message) * for outgoing call, send by SipEvent */ void -ManagerImpl::displayError (const string& error) +ManagerImpl::displayError (const std::string& error) { _debug("Display Error: %s\n", error.c_str()); if(_gui) { @@ -849,13 +831,25 @@ ManagerImpl::displayError (const string& error) * for outgoing call, send by SipEvent */ void -ManagerImpl::displayStatus (const string& status) +ManagerImpl::displayStatus (const std::string& status) { if(_gui) { _gui->displayStatus(status); } } +/** + * SipEvent Thread + * for outgoing call, send by SipEvent + */ +void +ManagerImpl::displayConfigError (const std::string& message) +{ + if(_gui) { + _gui->displayConfigError(message); + } +} + /** * SipEvent Thread * for outgoing call, send by SipEvent @@ -1023,48 +1017,12 @@ ManagerImpl::getStunInfo (StunAddress4& stunSvrAddr) { // Convert ipv4 address to host byte ordering in.s_addr = ntohl (mappedAddr.addr); addr = inet_ntoa(in); - _firewallAddr = string(addr); + _firewallAddr = std::string(addr); _debug("address firewall = %s\n",_firewallAddr.data()); } else { _debug("Opened a stun socket pair FAILED\n"); } } -/* -AudioDevice -ManagerImpl::deviceList (int index) -{ - AudioDevice deviceParam; - deviceParam.hostApiName = - portaudio::System::instance().deviceByIndex(index).hostApi().name(); - deviceParam.deviceName = - portaudio::System::instance().deviceByIndex(index).name(); - return deviceParam; -} - -int -ManagerImpl::deviceCount (void) -{ - int numDevices = 0; - - portaudio::AutoSystem autoSys; - portaudio::System &sys = portaudio::System::instance(); - numDevices = sys.deviceCount(); - return numDevices; -} - -bool -ManagerImpl::defaultDevice (int index) -{ - bool defaultDisplayed = false; - - portaudio::AutoSystem autoSys; - portaudio::System &sys = portaudio::System::instance(); - if (sys.deviceByIndex(index).isSystemDefaultInputDevice()) { - defaultDisplayed = true; - } - return defaultDisplayed; -} -*/ bool ManagerImpl::useStun (void) { @@ -1110,7 +1068,7 @@ ManagerImpl::callVectorSize (void) int ManagerImpl::createSettingsPath (void) { int exist = 1; - _path = string(HOMEDIR) + "/." + PROGNAME; + _path = std::string(HOMEDIR) + "/." + PROGNAME; if (mkdir (_path.data(), 0755) != 0) { // If directory creation failed @@ -1348,6 +1306,7 @@ ManagerImpl::getCallStatus(const std::string& sequenceId) // TODO: implement account std::string accountId = "acc1"; std::string code; + std::string status; TokenList tk; Call* call; @@ -1355,10 +1314,10 @@ ManagerImpl::getCallStatus(const std::string& sequenceId) CallVector::iterator iter = _callVector.begin(); while(iter!=_callVector.end()){ call = (*iter); - std::string status = call->getStatus(); switch( call->getState() ) { case Call::Busy: code="113"; + status = "Busy"; break; case Call::Answered: @@ -1368,14 +1327,17 @@ ManagerImpl::getCallStatus(const std::string& sequenceId) case Call::Ringing: code="111"; + status = "Ringing"; break; case Call::Progressing: code="110"; status="Trying"; break; + default: code="115"; + status="Other"; } // No Congestion // No Wrong Number diff --git a/src/managerimpl.h b/src/managerimpl.h index bd37a3702777460a39d51283388ed77a17bc8ecd..381b5cd799adf1d45e9c08d08f3510d83264dd11 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -183,6 +183,8 @@ public: void displayErrorText (short id, const std::string& message); void displayError (const std::string& error); void displayStatus (const std::string& status); + void displayConfigError(const std::string& message); + // int selectedCall (void); // bool isCurrentId (short id); void startVoiceMessageNotification (const std::string& nb_msg); diff --git a/src/sipcall.h b/src/sipcall.h index 1fdcf5189ff2bc04505785416923b48aa4e886c6..deeecb3d58e5d1d48ba334a0720860a67c27c0ab 100644 --- a/src/sipcall.h +++ b/src/sipcall.h @@ -34,10 +34,8 @@ class AudioCodec; #define _SENDONLY 1 #define _RECVONLY 2 -using namespace std; - // Vector of CodecDescriptor -typedef vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector; +typedef std::vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector; class SipCall { public: diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index fdfffe753d8df44ee8786a33fc1233ae1927a7a0..179d1b0d2c26ca7c2cbd11e35f3e3b83d353f798 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -19,8 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <string> - #include <eXosip2/eXosip.h> #include <osip2/osip.h> @@ -58,10 +56,12 @@ SipVoIPLink::SipVoIPLink (short id) } SipVoIPLink::~SipVoIPLink(void) { + endSipCalls(); eXosip_quit(); delete _evThread; _evThread = NULL; } +// for voIPLink interface void SipVoIPLink::terminate(void) { @@ -71,21 +71,16 @@ bool SipVoIPLink::checkNetwork (void) { // Set IP address - if (getLocalIp() == -1) { - // If no network - return false; - } else { - return true; - } + return getLocalIp(); } int SipVoIPLink::init (void) { - string tmp; + std::string tmp; int i; - tmp = string(PROGNAME) + "/" + string(VERSION); + tmp = std::string(PROGNAME) + "/" + std::string(VERSION); i = eXosip_init (); if (i != 0) { @@ -188,11 +183,11 @@ SipVoIPLink::setRegister (void) std::string from = fromHeader(manager.getConfigString(SIGNALISATION, USER_PART), manager.getConfigString(SIGNALISATION, HOST_PART)); if (manager.getConfigString(SIGNALISATION, HOST_PART).empty()) { - manager.error()->errorName(HOST_PART_FIELD_EMPTY); + manager.displayConfigError("Fill host part field"); return -1; } if (manager.getConfigString(SIGNALISATION, USER_PART).empty()) { - manager.error()->errorName(USER_PART_FIELD_EMPTY); + manager.displayConfigError("Fill user part field"); return -1; } @@ -285,10 +280,10 @@ SipVoIPLink::setUnregister (void) } int -SipVoIPLink::outgoingInvite (short id, const string& to_url) +SipVoIPLink::outgoingInvite (short id, const std::string& to_url) { - string from; - string to; + std::string from; + std::string to; // TODO: should be inside account settings ManagerImpl& manager = Manager::instance(); @@ -298,7 +293,7 @@ SipVoIPLink::outgoingInvite (short id, const string& to_url) to = toHeader(to_url); - if (to.find("@") == string::npos and + if (to.find("@") == std::string::npos and manager.getConfigInt(SIGNALISATION, AUTO_REGISTER)) { to = to + "@" + manager.getConfigString(SIGNALISATION, HOST_PART); } @@ -320,7 +315,7 @@ SipVoIPLink::outgoingInvite (short id, const string& to_url) return 0; } else { // If SIP proxy setting - string route = "<sip:" + + std::string route = "<sip:" + manager.getConfigString(SIGNALISATION, PROXY) + ";lr>"; if (checkNetwork()) { if (startCall(id, from, to, "", route) <= 0) { @@ -400,8 +395,7 @@ SipVoIPLink::hangup (short id) id, sipcall->getCid(), sipcall->getDid()); // Release SIP stack. eXosip_lock(); - i = eXosip_call_terminate (sipcall->getCid(), - sipcall->getDid()); + i = eXosip_call_terminate (sipcall->getCid(), sipcall->getDid()); eXosip_unlock(); // Release RTP channels @@ -427,6 +421,7 @@ SipVoIPLink::cancel (short id) i = eXosip_call_terminate (sipcall->getCid(), -1); eXosip_unlock(); } + deleteSipCall(id); return i; } @@ -560,13 +555,13 @@ SipVoIPLink::offhold (short id) } int -SipVoIPLink::transfer (short id, const string& to) +SipVoIPLink::transfer (short id, const std::string& to) { osip_message_t *refer; int i; - string tmp_to; + std::string tmp_to; tmp_to = toHeader(to); - if (tmp_to.find("@") == string::npos) { + if (tmp_to.find("@") == std::string::npos) { tmp_to = tmp_to + "@" + Manager::instance().getConfigString(SIGNALISATION, HOST_PART); } @@ -920,7 +915,7 @@ SipVoIPLink::getEvent (void) std::string str(body->body); pos = str.find(VOICE_MSG); - if (pos == string::npos) { + if (pos == std::string::npos) { // If the string is not found returnValue = -1; break; @@ -1034,6 +1029,16 @@ SipVoIPLink::deleteSipCall (short callid) } } +void +SipVoIPLink::endSipCalls() +{ + std::vector< SipCall * >::iterator iter = _sipcallVector.begin(); + while(iter != _sipcallVector.end()) { + hangup( (*iter)->getId() ); + iter++; + } +} + SipCall* SipVoIPLink::getSipCall (short callid) { @@ -1238,7 +1243,7 @@ SipVoIPLink::behindNat (void) stunSvrAddr.addr = 0; // Stun server - string svr = Manager::instance().getConfigString(SIGNALISATION, STUN_SERVER); + std::string svr = Manager::instance().getConfigString(SIGNALISATION, STUN_SERVER); // Convert char* to StunAddress4 structure bool ret = stunParseServerName ((char*)svr.data(), stunSvrAddr); @@ -1254,19 +1259,26 @@ SipVoIPLink::behindNat (void) return 1; } -int +/** + * Get the local Ip by eXosip + * setLocalIpAdress + * @return false if not found + */ +bool SipVoIPLink::getLocalIp (void) { - int ret = 0; + bool returnValue = true; char* myIPAddress = new char[65]; - ret = eXosip_guess_localip (AF_INET, myIPAddress, 64); + if (eXosip_guess_localip (AF_INET, myIPAddress, 64) == -1) { + returnValue = false; + } setLocalIpAddress(std::string(myIPAddress)); delete [] myIPAddress; myIPAddress = NULL; - return ret; + return returnValue; } int -SipVoIPLink::checkUrl (const string& url) +SipVoIPLink::checkUrl (const std::string& url) { int i; @@ -1298,7 +1310,7 @@ SipVoIPLink::setAuthentication (void) } pass = manager.getConfigString(SIGNALISATION, PASSWORD); if (pass.empty()) { - manager.error()->errorName(PASSWD_FIELD_EMPTY); + manager.displayConfigError("Fill password field"); return -1; } int returnValue = 0; @@ -1311,16 +1323,16 @@ SipVoIPLink::setAuthentication (void) return returnValue; } -string -SipVoIPLink::fromHeader (const string& user, const string& host) +std::string +SipVoIPLink::fromHeader (const std::string& user, const std::string& host) { - string displayname = Manager::instance().getConfigString(SIGNALISATION, + std::string displayname = Manager::instance().getConfigString(SIGNALISATION, FULL_NAME); return ("\"" + displayname + "\"" + " <sip:" + user + "@" + host + ">"); } -string +std::string SipVoIPLink::toHeader(const string& to) { if (to.find("sip:") == string::npos) { @@ -1331,8 +1343,8 @@ SipVoIPLink::toHeader(const string& to) } int -SipVoIPLink::startCall (short id, const string& from, const string& to, - const string& subject, const string& route) +SipVoIPLink::startCall (short id, const std::string& from, const std::string& to, + const std::string& subject, const std::string& route) { SipCall *sipcall = getSipCall(id); if ( sipcall == NULL) { @@ -1342,7 +1354,7 @@ SipVoIPLink::startCall (short id, const string& from, const string& to, int i; if (checkUrl(from) != 0) { - Manager::instance().error()->errorName(FROM_ERROR); + Manager::instance().displayConfigError("Error for 'From' header"); return -1; } if (checkUrl(to) != 0) { diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index 285a5052abffbe897140a7095fce9ece1ebdb7eb..cb3c65c6318b594a64f1cd59b641e8365f699bbe 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -30,8 +30,6 @@ #include "voIPLink.h" #include "audio/audiortp.h" -using namespace std; - #define EXPIRES_VALUE 180 // To build request #define INVITE_METHOD "INVITE" @@ -66,7 +64,7 @@ class CodecDescriptor; class SipCall; class EventThread; -typedef vector< CodecDescriptor* > CodecDescriptorVector; +typedef std::vector< CodecDescriptor* > CodecDescriptorVector; class SipVoIPLink : public VoIPLink { public: @@ -78,13 +76,13 @@ public: virtual void terminate (void); virtual int setRegister (void); virtual int setUnregister (void); - virtual int outgoingInvite (short id, const string& to_url); + virtual int outgoingInvite (short id, const std::string& to_url); virtual int answer (short id); virtual int hangup (short id); virtual int cancel (short id); virtual int onhold (short id); virtual int offhold (short id); - virtual int transfer (short id, const string& to); + virtual int transfer (short id, const std::string& to); virtual int refuse (short id); virtual int getEvent (void); virtual void carryingDTMFdigits (short id, char code); @@ -131,17 +129,17 @@ private: int behindNat (void); /* - * To Store the local IP address, and allow to know if the network is + * To Store the local IP address, and allow to know if the network is * available. * - * Return -1 if an error occured and 0 if no error + * Return false if an error occured and true if no error */ - int getLocalIp (void); + bool getLocalIp (void); /* * Return -1 if an error occured and 0 if no error */ - int checkUrl(const string& url); + int checkUrl(const std::string& url); /* * Allow the authentication when you want register @@ -154,14 +152,14 @@ private: * Example: "Display user name" <sip:user@host.com> * Return the result in a string */ - string fromHeader (const string& user, const string& host); + std::string fromHeader (const std::string& user, const std::string& host); /* * Build a sip address with the number that you want to call * Example: sip:124@domain.com * Return the result in a string */ - string toHeader(const string& to); + std::string toHeader(const std::string& to); /* * Beginning point to make outgoing call. @@ -170,8 +168,8 @@ private: * Build SDP body. * Return -1 if an error occured and 0 if no error */ - int startCall (short id, const string& from, const string& to, - const string& subject, const string& route); + int startCall (short id, const std::string& from, const std::string& to, + const std::string& subject, const std::string& route); /* * Look for call with same cid/did @@ -206,6 +204,11 @@ private: */ void subscribeMessageSummary(); + /** + * End all sip call not deleted + */ + void endSipCalls(); + /////////////////////////// // Private member variables /////////////////////////// diff --git a/src/voIPLink.h b/src/voIPLink.h index 54b35de28ebb4c636e6948be420f6127ce8a2bbb..c9c6209c77a937ca2a27f2c0352ac613b01661a0 100644 --- a/src/voIPLink.h +++ b/src/voIPLink.h @@ -23,8 +23,6 @@ #include <string> -using namespace std; - enum VoIPLinkType { Sip = 0, Iax @@ -45,14 +43,13 @@ public: virtual void terminate (void) = 0; virtual void newOutgoingCall (short callid) = 0; virtual void newIncomingCall (short callid) = 0; - virtual void deleteSipCall (short callid) = 0; - virtual int outgoingInvite (short id, const string& to_url) = 0; + virtual int outgoingInvite (short id, const std::string& to_url) = 0; virtual int answer (short id) = 0; virtual int hangup (short id) = 0; virtual int cancel (short id) = 0; virtual int onhold (short id) = 0; virtual int offhold (short id) = 0; - virtual int transfer (short id, const string& to) = 0; + virtual int transfer (short id, const std::string& to) = 0; virtual int refuse (short id) = 0; virtual int setRegister (void) = 0; virtual int setUnregister (void) = 0; @@ -63,12 +60,12 @@ public: short getId (void); void setType (VoIPLinkType type); VoIPLinkType getType (void); - void setFullName (const string& fullname); - string getFullName (void); - void setHostName (const string& hostname); - string getHostName (void); - void setLocalIpAddress (const string& ipAdress); - string getLocalIpAddress (void); + void setFullName (const std::string& fullname); + std::string getFullName (void); + void setHostName (const std::string& hostname); + std::string getHostName (void); + void setLocalIpAddress (const std::string& ipAdress); + std::string getLocalIpAddress (void); protected: @@ -78,9 +75,9 @@ private: short _id; VoIPLinkType _type; - string _fullname; - string _hostname; - string _localIpAddress; + std::string _fullname; + std::string _hostname; + std::string _localIpAddress; }; #endif // __VOIP_LINK_H__