diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h index a2ba90cc26fe2cbaf5d47def4ba0ce7f861c3b97..b19eb1b7745f7280a1fc26cffe9c596b8ad5d14d 100644 --- a/src/gui/guiframework.h +++ b/src/gui/guiframework.h @@ -35,8 +35,8 @@ public: /* Parent class to child class */ virtual int incomingCall (short id, const std::string& accountId, const std::string& from) = 0; virtual void peerAnsweredCall (short id) = 0; - virtual int peerRingingCall (short id) = 0; - virtual int peerHungupCall (short id) = 0; + virtual void peerRingingCall (short id) = 0; + virtual void peerHungupCall (short id) = 0; virtual void displayStatus (const std::string& status) = 0; virtual void displayConfigError (const std::string& error) = 0; virtual void displayTextMessage (short id, const std::string& message) = 0; diff --git a/src/gui/server/guiserverimpl.cpp b/src/gui/server/guiserverimpl.cpp index 40c4b153fc63d5cfd16a2adc1042487fc5dfdb92..cfd0367ca8b839cdaa908730c07796b9eec0ec97 100644 --- a/src/gui/server/guiserverimpl.cpp +++ b/src/gui/server/guiserverimpl.cpp @@ -244,6 +244,10 @@ GUIServerImpl::hangupCall(const std::string& callId) return false; } +/* + * we hangup everything in callmap, and flush it + * @return false if atleast one hangup failed + */ bool GUIServerImpl::hangupAll() { @@ -303,8 +307,7 @@ GUIServerImpl::incomingCall (short id, const std::string& accountId, const std:: insertSubCall(id, subcall); - _requestManager.sendResponse(ResponseMessage("001", _getEventsSequenceId, -arg)); + _requestManager.sendResponse(ResponseMessage("001", _getEventsSequenceId,arg)); return 0; } @@ -315,39 +318,32 @@ GUIServerImpl::peerAnsweredCall (short id) CallMap::iterator iter = _callMap.find(id); if ( iter != _callMap.end() ) { _requestManager.sendResponse(ResponseMessage("200", iter->second.sequenceId(), "OK")); - } else { - std::ostringstream responseMessage; - responseMessage << "Peer Answered Call: " << id; - _requestManager.sendResponse(ResponseMessage("500", _getEventsSequenceId, -responseMessage.str())); } } -int +void GUIServerImpl::peerRingingCall (short id) { CallMap::iterator iter = _callMap.find(id); if ( iter != _callMap.end() ) { _requestManager.sendResponse(ResponseMessage("151", iter->second.sequenceId(), "Ringing")); } - return 0; } -int +void GUIServerImpl::peerHungupCall (short id) { CallMap::iterator iter = _callMap.find(id); if ( iter != _callMap.end() ) { - std::ostringstream responseMessage; - responseMessage << iter->second.callId() << " hangup"; + TokenList tk; + tk.push_back(iter->second.callId()); + tk.push_back("hangup"); - _requestManager.sendResponse(ResponseMessage("002", _getEventsSequenceId, -responseMessage.str())); + _requestManager.sendResponse(ResponseMessage("002", _getEventsSequenceId,tk)); // remove this call... _callMap.erase(id); } - return 0; } void @@ -453,9 +449,10 @@ GUIServerImpl::callFailure(short id) { CallMap::iterator iter = _callMap.find(id); if ( iter != _callMap.end() ) { - std::ostringstream responseMessage; - responseMessage << iter->second.callId() << " Wrong number"; + TokenList tk; + tk.push_back(iter->second.callId()); + tk.push_back("Wrong number"); - _requestManager.sendResponse(ResponseMessage("504", iter->second.sequenceId(), responseMessage.str())); + _requestManager.sendResponse(ResponseMessage("504", iter->second.sequenceId(), tk)); } } diff --git a/src/gui/server/guiserverimpl.h b/src/gui/server/guiserverimpl.h index 8a14759bac7f1256467d566a56e5ab742b3b29ab..648fb66e3a73589748e0cc19fd495ad0f14675e9 100644 --- a/src/gui/server/guiserverimpl.h +++ b/src/gui/server/guiserverimpl.h @@ -44,8 +44,8 @@ public: int incomingCall(short id, const std::string& accountId, const std::string& from); void peerAnsweredCall (short id); - int peerRingingCall (short id); - int peerHungupCall (short id); + void peerRingingCall (short id); + void peerHungupCall (short id); void displayStatus (const std::string& status); void displayConfigError(const std::string& error); void displayTextMessage (short id, const std::string& message); diff --git a/src/gui/server/responsemessage.cpp b/src/gui/server/responsemessage.cpp index 34c2715e7a0c3b1a9d4f084ea7da45b3c7a73b6b..dd52c3fe1902182356749c026f0f03c399a35f68 100644 --- a/src/gui/server/responsemessage.cpp +++ b/src/gui/server/responsemessage.cpp @@ -29,14 +29,8 @@ ResponseMessage::ResponseMessage(const std::string& code, const std::string& seq, const std::string& message) : _code(code), _seq(seq) { - int len = message.length(); - if (len) { - char *tmp = new char[len*3+2]; - ost::urlEncode(message.c_str(), tmp, len*3+2); - // we don't have to put a '\0' right? - _message = tmp; - delete [] tmp; tmp = NULL; - } + _message = ""; + appendMessage(message); } /* @@ -49,20 +43,13 @@ ResponseMessage::ResponseMessage(const std::string& code, { TokenList::iterator iter=arg.begin(); if (iter!=arg.end()) { - _message = *iter; + appendMessage(*iter); iter++; } // add space between each while(iter!=arg.end()) { _message.append(" "); - int len = iter->length(); - if (len) { - char *tmp = new char[len*3+2]; - ost::urlEncode(iter->c_str(), tmp, len*3+2); - // we don't have to put a '\0' right? - _message.append(tmp); - delete [] tmp; tmp = NULL; - } + appendMessage(*iter); iter++; } } @@ -102,4 +89,16 @@ ResponseMessage::isFinal() const return final; } +void +ResponseMessage::appendMessage(const std::string& strToken) +{ + int len = strToken.length(); + if (len) { + char *tmp = new char[len*3+2]; + ost::urlEncode(strToken.c_str(), tmp, len*3+2); + // we don't have to put a '\0' right? + _message.append(tmp); + delete [] tmp; tmp = NULL; + } +} diff --git a/src/gui/server/responsemessage.h b/src/gui/server/responsemessage.h index 906b8df415b10e12440619a5b6091b266ed41cec..093c1f3ed0e0ba85d742b5388238f543be6e2b43 100644 --- a/src/gui/server/responsemessage.h +++ b/src/gui/server/responsemessage.h @@ -42,7 +42,10 @@ public: std::string toString() const; bool isFinal() const; private: - // 3 numbers long sequenceId + // append an encoded string to the message + void appendMessage(const std::string& strToken); + + // 3 numbers long code std::string _code; std::string _seq; std::string _message; diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index f3ca217d1ec84b2deaf783cad6d27793c0c71d2d..fdfffe753d8df44ee8786a33fc1233ae1927a7a0 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -310,8 +310,8 @@ SipVoIPLink::outgoingInvite (short id, const string& to_url) // If no SIP proxy setting for direct call with only IP address if (checkNetwork()) { if (startCall(id, from, to, "", "") <= 0) { - _debug("Warning SipVoIPLink: call not started\n"); - return -1; + _debug("Warning SipVoIPLink: call not started\n"); + return -1; } } else { manager.displayErrorText(id, "No network found\n"); @@ -324,8 +324,8 @@ SipVoIPLink::outgoingInvite (short id, const string& to_url) manager.getConfigString(SIGNALISATION, PROXY) + ";lr>"; if (checkNetwork()) { if (startCall(id, from, to, "", route) <= 0) { - _debug("Warning SipVoIPLink: call not started\n"); - return -1; + _debug("Warning SipVoIPLink: call not started\n"); + return -1; } } else { manager.displayErrorText(id, "No network found\n");